Lexicographically smallest string after swaps.
Unlock detailed company stats for this questionUpgrade
Given a string and two arrays arr and brr of pairs of indices, swap characters at positions arr[j] and brr[j] any number of times and return the lexicographically smallest string. Example: s = "cab", arr = [0,0], brr = [1,2] gives "abc". s has only lowercase letters, n <= 10^5 and 0 <= m <= n.
Community answers
No answers contributed by the community yet.
Related questions
Build the lexicographically smallest string with a subsequence.Find the lexicographically smallest grid path with one slip allowed.Replace '?' characters to minimize a string's total penalty, returning the lexicographically smallest result.Related courses

Course

Course
Course
