Smallest String With Swaps
Medium
Union-Find (Advanced)
You are given a string and pairs of indices; any two characters at paired indices may be swapped any number of times. Print the lexicographically smallest string you can obtain.
Constraints
1 <= len(s) <= 10^5 0 <= p <= 10^5
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.