BlackRock interview question

Inverse a sentence.

Interview Answers

Anonymous

Jan 28, 2015

Reverse complete sentence as string reverse. Then reverse every word in it (using two variable i and j for index to hold one word, we can find word when we encounter space). Runtime O(n) + O(n) where n is length of string. no extra space required, everything is happening in-place

1

Anonymous

Aug 7, 2014

Tokenize the string... put each token in a stack... pop the stack and print it.

Anonymous

Jan 31, 2013

Just go through the sentence...