Twitter Phone Interview -
Duration: 1 hr
Platform: Hackerrank - codepair
- Write a collection of data structure that is fast (should run in o(1) time amortized) for each of the follwoing operation - add(element), remove(element), get(element)
- Given a list of leaf nodes, return a list containing all the nodes of the tree in DFS order.
'''
class Node{
int id;
List parentIds; //this will be in the descending order in terms of the precedence of the parents.
}
'''
Example: Given a tree

Input List -{3,5}
o/p: {1,2,3,4,5}