But it doesn't have to end here! Sign up for the 7-day coding interview crash course and you'll get a free Interview Cake problem every week.
You're in!
You're working on a secret team solving coded transmissions.
Your team is scrambling to decipher a recent message, worried it's a plot to break into a major European National Cake Vault. The message has been mostly deciphered, but all the words are backward! Your colleagues have handed off the last step to you.
Write a method reverseWords that takes a message as an array of characters and reverses the order of the words in place.
Why an array of characters instead of a string?
The goal of this question is to practice manipulating strings in place. Since we're modifying the message, we need a mutable type like an array, instead of Java's immutable strings.
For example:
When writing your method, assume the message contains only letters and spaces, and all words are separated by one space.
We can do this in space. Remember, in place.
We can do this in time.
If you're swapping individual words one at a time, consider what happens when the words are different lengths. Isn't each swap time in the worst case?
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
time and space!
Hmm, the team used your method to finish deciphering the message. There definitely seems to be a heist brewing, but no specifics on where. Any ideas?
How would you handle punctuation?
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
Wanna review this one again later? Or do you feel like you got it all?
Mark as done Pin for review laterReset editor
Powered by qualified.io