Sorting the Sentence
A shuffled sentence s has words separated by single spaces, and each word ends with a single digit from 1 to 9 giving its position in the original sentence. Return the original sentence with the digits removed and the words in position order, separated by single spaces.
Example 1
s "is2 sentence4 This1 a3"
returns "This is a sentence"
Position order gives This is a sentence.
Constraints
1 <= number of words <= 9- The digits used are exactly
1up to the number of words
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Sorting and searching problems
- Find in a Mountain ListMedium
- Find in a Rotated ListMedium
- H-IndexMedium
- K Closest ValuesMedium
- Kth Smallest Pair SumMedium
- Least Truck CapacityMedium
- Merge IntervalsMedium
- Rebuild the LineMedium