Company: Capital one oncampus_11june
Difficulty: medium
You are given a string inputStr containing only the letters W , D , and L . Your task is to construct a new string from the characters of inputStr according to the following algorithm: Begin with an empty string output = "" . If inputStr does NOT contain any W s, proceed to step 3. Otherwise, remove any one of the W s from the inputStr , append a W to the end of output , and proceed to step 3. If inputStr does NOT contain any D s, proceed to step 4. Otherwise, remove any one of the D s from the inputStr , append a D to the end of output , and proceed to step 4. If inputStr does NOT contain any L s, proceed to step 5. Otherwise, remove any one of the L s from the inputStr , append an L to the end of output , and proceed to step 5. If inputStr is empty, end the algorithm; otherwise, go back to step 2. Return the value of output after the algorithm is complete. Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(inputStr.le