First round :
After introduction, I got these three questions.
1) Write a method to decide if two strings are anagrams or not (with O(N) complexity).
2) Given a directed graph, design an algorithm to find out whether there is a route be-
tween two nodes
3) one sql query with out joins.
Second round:
After introduction, why you are looking for job change.
1. Find most frequently occurred word(s) in the following statement,
"XYZ is employee of ABC company, Xyz is from blore, XYZ! is good in java."
2. Identify the root parent fo given person. Need solution for both Iterative and recursive solutions. which one is better and why?
d -> c -> b -> a -> e -> f -> g-> h
public class Person {
private Person parent;
public Person(Person parent) {
this.parent = parent;
}
public Person getParent() {
return parent;
}
}
3. extension to 2, identify if there is any loop in the given nodes. using both iterative and recursive.(this interviewer doesn't know whats slow and fast pointer approach(Tortoise and Rabbit approach))
d -> c -> b -> a -> e -> f -> g-> h -> d
4.Create a dataStructure for LRU(Least recent used) value
data structure of N capacity with LRU(Least recently used) mechanism
ex: datastructure of size 2
.put(1, A); // {1=A}
.put(2, B); // {1=A, 2=B}
.get(1); // return A
.put(3, C); // LRU key was 2, key 2 is removed,{1=A, 3=C}
.get(2); // if not found,returns null
.put(4, D) // LRU key was 1, key 1 is removed , {4=D, 3=C}
.get(3); // return C