Loading...
Engaged Employer
Write a function to remove repeated spaces from a string (ex: "one two three four" -> "one two three four")
Anonymous
Just use 2 pointers to walk through and modify the string in place.
If my understanding is correct. Just "xxx".split("\\s+") and put them back together. Took within 10 lines of code.
I forgot to mention that do trim() first before split.
Javascript version: ' This is a test '.trim().replace(/\ {2,}/g, ' ')
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.