Twitter Phone Interview
Anonymous User
6582

Twitter Phone Interview -

Duration: 1 hr
Platform: Hackerrank - codepair

  1. 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)
  2. 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
image

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

Comments (9)