Reverse words
MediumGiven an array of characters that make up a sentence, return an array of character that reverse the words in a sentence.
For example, consider this input:
['b', 'i', 't', 'c', 'o', 'i', 'n', ' ', 'i', 's', ' ', 'u', 'p']
Your function should return:
['u', 'p', ' ', 'i', 's', ' ', 'b', 'i', 't', 'c', 'o', 'i', 'n']
Bonus: Can you do it in place without allocating a new array?
Try it
Solution
6 Essential Strings Coding Interview Problems
Master Strings by trying the coding challenges below.
- 1.Reverse StringEasy
- 2.AnagramEasy
- 3.Reverse wordsMedium
- 4.String matchMedium
- 5.CompressionMedium
- 6.One edit awayHard