Stack Bash - Master data structures and algorithms

Reverse words

Medium
Given 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. 1.Reverse StringEasy
  2. 2.AnagramEasy
  3. 3.Reverse wordsMedium
  4. 4.String matchMedium
  5. 5.CompressionMedium
  6. 6.One edit awayHard

Want to confidently pass your next coding interview?

Stack Bash helps new and veteran software engineers master data structures and algorithms for technical interviews.