Q1
Reverse characters of each word in a sentence
--------- "my career stack" ---------
Reverse the characters of each word, keeping the order of the words same such
that the output will be
--------- "ym reerac kcats" ---------
Q2
Minimum cost for painting a row houses in three different colors
Find the color of each house such that no two adjacent house have the same color and the total cost of coloring all the houses is minimum.
Update: The question intends to state that cost of painting any house in any color is different, so if cost of painting House 1 in Red is say, X then the cost of painting House 2 in red will some other value Y. It can be considered each house has different dimensions and hence cost of painting in each color is different, and the cost of paint for each house also varies
Q3
Given a preorder and a postorder traversal, construct the tree.
Q4
How to convert singly linked list to binary search tree?
Q5
Find the intervals from a set of intervals in which a given point lies
Q6
What is the minimum number of comparisons required to find the largest and the second largest elements in an array
If it makes your life easier you can use extra space. But try to keep it less.
Q7
Number of occurrences of a number in a sorted array.
Q8
Validate a Binary Search Tree
Q9
Find out all unique triplets in a set such that there sum is zero
For example, given set S = {-1 0 1 2 -1 -4},
One possible solution set is:
(-1, 0, 1)
(-1, 2, -1)
Note that (0, 1, -1) is not part of the solution above, because (0, 1, -1) is the duplicate of (-1, 0, 1). Same with (-1, -1, 2).
For a set S, there is probably no "the" solution, another solution could be:
(0, 1, -1)
(2, -1, -1)
Q10
Find Least height tree of an acyclic undirected unweighted connected graph?