Reverse words in a sentence

Given an array of characters, reverse the words in the sentence.
For example, if the sentence is "Reverse these words", then the output should be "words these reverse".

Source : this interview q

Find duplicates in an array

Given an array of size 'n', containing elements from 1 to 'n', find out if there are any duplicates in the array. Solve this, if
  • a single duplicate number exists
  • multiple duplicate numbers exist
 Source : CLRS & this blog question (that I did not get)

Find subarray with maximum sum

Given an array of size n, containing positive and negative integers, find the longest sub-array such that the sum of the elements in the sub-array is the maximum.

For example,
Given array :
10, 8, -5, 1, -27, 5, 7, -5, 11
the sub array should be : 10, 8

Source : CLRS & this sample interview question
 
Stats