My Blog List

[Leetcode Solution] Reverse Words in a String

Long time no coding, each line needs a cplusplus.com look up : (

Analysis

Programming is straightforward. Extract words from input string using space as delimiter. Write words back to input string in reverse order.

Code

http://fmarss.blogspot.com/2014/10/divide-array-into-sub-arrays.html 


Coding Note

  • Clarification is very important during the interview (Yu's Coding). Make sure following trifles such as 
    1. what's the delimiter
    2. only lower case letters included?
    3. leading trailing or multiple space contained?
    4. empty string input?
Divide an array by given delimiter and perform calculation on each sub array. Code Template can be found here