Google Interview Question

Reverse the word order in a string.

Interview Answers

Anonymous

Oct 7, 2010

Flip entire string, then flip individual words.

2

Anonymous

Jul 2, 2019

// In java String str[]=givenString.split(" "); for(int a=str.length-1;a>=0;a--) System.out.print(str[a]+" ");

Anonymous

Jan 7, 2011

Use String Tokenizer to parse words from string and subsequently push each word onto a stack. When there are no more tokens, pop the stack and concatenate back into string.

2