AlphaGrep, Recently Asked Online Assessments, 5th December, 2022 | Characters Swap | Subsegment Sort
Alphagrep · Question · Posted Dec 2022
Question 1 <problem>284</problem> Characters Swap Given a string s, repeat this operation zero or more times to create the lexicographically smallest string possible. Select two characters that exist in the string, c1 and c2. Replace all occurrences of c1 with c2 and all occurrences of c2 with c1. Note: For two strings x and y of length n, x is lexicographically smaller than y if the first non-matching character in x is less than the character at that position in ...
The full answer & interview discussion are available to premium members.
Log in Create a free account