Recent Interview Questions
More Questions » 0of 0 votes
Albert Grithum teaches seven and eight year olds. Today is school picture day and everybody,
including the teacher, has lined up in a single line for the class picture. Initially
everyone has lined up in a random order. The photographer wants the following arrangement
from left to right: first, all of the seven year olds, in order of increasing height. Next,
Mr. Grithum in the middle. Last, the eight year olds in decreasing order of height. The
only adjustment allowed is a swap, in which two neighboring people swap their positions.
Design an O(n log n) Java code that computes the minimum number of swaps necessary to
get the class into the desired order
 0of 0 votes
Given is a large paper with n different points with coordinates (x1, y1),(x2, y2), . . . ,(xn, yn).
Notice that by folding the paper along a single line we can make some of the points align.
For example, if the points are (1,2), (2,1), and (4,3), then if we fold along the line going
through the origin at the 45 degree angle, the points (1,2) and (2,1) will align. Design
an O(n^2log n) Java code that finds the maximum number of pairs of points that can be
aligned.
 0of 0 votes
Define a function that can detect whether the characters of a string can be shuffled without repeating same characters as one other's neighbors. E.g. :
apple >> alpep, so valid
a >> a, valid
aa >> aa, invalid/impossible
aab >> aba, valid
aaaabbcc >> acabacab, valid
etc.
You do not have to find one representation, just have to detect if it is possible or not!
 0of 0 votes
Given a table with id and value ,
======
id value
======
101 100
102 150
101 80
101 200
102 120
======
Find the median value using SQL. Goes without saying that you can't use MEDIAN function of Oracle SQL.
output:
101 100
102 175
 0of 0 votes
