Twitter Interview | Set 1

Phone screen – I

1. Fibonacci series without using an array – this is a typical favorite question w.r.t. Dynamic Programming where you will asked not to use Memoization or any extra storage to store the values of the previous iterations.
(More complicated version of the same problem: Generate Nth row of pascal’s triangle w/o using a 2D array of dimention N x N)

2. N-ary tree : find if a node exists in the tree with value = x. If yes, return true, else, return false.

Phone screen – II
1. Find the lowest common ancestor of Binary Tree
Answer: Done it a 10 times :) Explained how to do it !

2. Clone a graph and analyze the time and space complexity (since DFS based approaches leverages smaller time at the cost higher memory)

public class Node {
   public int data;
   List neighbhors;

   public Node (int data) {…}
   setNeighbors(List neighbhors) {…}

// HashMap created = new HashMap();

public Node clone(Node oldGraph) {

  if (created.get(oldGraph))
    return created.get(oldGraph);

  Node newGr = new Node(;
  List nbors = new ArrayList();

  created.put(oldGraph, newGr);

  List adj = oldGraph.getNeighbhors();
  for (Node n : adj) {

  return newGr;

Phone Screen III

Design a bloom filter to remove the duplicates from an unsorted array !


1. (Boggle – like question) In a 2D array (M x N, in the given ex. 3×3) of numbers, find the strictly increasing path from the specified origin cell (1,0) to the specified destination cell (0, 2). Array may contain duplicates, and solution should work with the dups.

2.a. Design a unique hash function for every tweet in Twitter which will be used as part of a service.
2.b. Find if a directed graph has cycles or not. Write a function with boolean return type for the same.

3. Casual Lunch interview.

4. Pattern matching using patterns containing chars (a to z) and ‘*’ , ‘?’ and ‘.’

5.a. Describe how would you do external sort -> come to a map-reduce kind of solution. Each machine has 10M numbers (total 100M), 10 total machines. Each m/c has 20MB RAM and 50GB memory.
5.b. N-Queens problem: find and print all possible non-conflicting positions for the Queen.

6.a. Given an input binary tree and reference to a Node in the tree, find next in-order successor for the input node. Output null if none.
6.b. What is the best way to sort a k-sorted array ? Optimize for time complexity.
(My hint: use a priority queue of size k)

7.a. Hiring manager: Design a service for a. Durability b. Consistency
7.b. Explain C++’s problem with multiple inheritance.

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

  • Bera

    Is it an Off-campus selection procedure? How did you apply for it?

  • ajayn1609
  • Shubham Gupta

    The best way to do is pick up an array of 2×2 suppose A=[1 1;1 0] and the array may be written as AF(n-1)=F(n) where F(n)=[a(n);a(n-1)] and a(n)=nth element of fibonnaci series. Assuming you take F(1)=[1;1]. And for Getting a(n) just multiply A^n to F(1).

  • Eric Khushwaha

    Phone screen – 1


    int main()


    int a=0,b=1,c;

    int n=10 // 10 terms of Fibonacci series



    printf(“%d “,b);







    /* Breadth-First Search Algorithm of an N-nary Tree (Finding node with value=DV )*/
    Node-ptr := find-if-node-exists (A-DV, An-NTree);
    /* Assumptions:
    (i) An-NTree is a pointer and it points to the Root node of the given N-nary tree; */
    /* Case # 1: If the given An-NTree is empty, then return null value */
    If (An-NTree.Son-Ptr == null)
    then return (null);
    /* Case # 2: A generic NTree of ‘N’ number of nodes and of ‘m’ depth (N > 0 AND m > 0); Create an empty queue, T-Queue */
    T-Queue : = Create-Empty-Queue ():
    T-Queue := Push-pointer (An-NTree, T-Queue);
    While (T-Queue is not empty) do
    T-Current-Node-Ptr := Pop-pointer (T-Queue);
    If ( == A-DV)
    then return (T-Current-Node-Ptr);
    T-Current-Node-Ptr := T-Current-Node-Ptr.Son-Ptr;
    If (T-Current-Node-Ptr != null)
    then begin
    T-Queue := Push-pointer (T-Current-Node-Ptr, T-Queue);
    While (T-Current-Node-Ptr.Sibling-Ptr != null) do
    T-Current-Node-Ptr := T-Curent-Node-Ptr.Sibling-Ptr;
    T-Queue := Push-pointer(T-Current-Node-Ptr, T-Queue);
    return (NULL)

  • Vikrant

    Question are really tough, anyone please explain how to solve each question?

  • pefullarton

    off campus? How did you apply for it?

    • reply

      Hi ,can you please help us with applying ?

  • Dumbo

    Was it a campus interview , or offcampus ?