## 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(oldGraph.data); List nbors = new ArrayList(); created.put(oldGraph, newGr); List adj = oldGraph.getNeighbhors(); for (Node n : adj) { nbors.add(clone(n)); } newGr.setNeighbors(nbors); return newGr; }

**Phone Screen III**

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

**On-site**

**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 contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

### Related Topics:

- Intuit Interview | Set 3 (For SE-2)
- [TopTalent.in] Exclusive Interview with Abhishek who got into DE Shaw
- Amazon Interview experience | Set 127 (For Internship)
- Linkedin Intership Interview for Software development Engineer
- Citrix Interview | Set 2 (Written Test Experience)
- Samsung R & D Interview Experience for Internship
- Interview Experience with Indus Valley Partners
- Amazon Interview experience | Set 126 (For SDE-1)

Writing code in comment?Please useideone.comand share the link here.