1202. Smallest String With Swaps
Description
**Input:** s = "dcab", pairs = [[0,3],[1,2]]
**Output:** "bacd"
**Explaination:**
Swap s[0] and s[3], s = "bcad"
Swap s[1] and s[2], s = "bacd"**Input:** s = "dcab", pairs = [[0,3],[1,2],[0,2]]
**Output:** "abcd"
**Explaination:**
Swap s[0] and s[3], s = "bcad"
Swap s[0] and s[2], s = "acbd"
Swap s[1] and s[2], s = "abcd"ac
Last updated