Algorithm · PayPal · Hard
Given a string s consisting only of lowercase English letters and a list pairs of allowed swaps. Each entry [a, b] means you may swap the characters located at positions a and b. You can perform any number of swaps, in any order, and the same allowed pair may be reused as many times as needed. All indices in this problem are zero-based. Return the lexicographically smallest version of s that can be produced after applying some valid sequence of swaps. Example 1: Explanation:…
Checking your access…