# Grab Interview Questions

Coding round questions

• In an integer array, find a pair of numbers which add up to a given number.

``->->->->->after plus 1->->->->->``
• Find the count of all perfect squares between two numbers a and b.

• Given an array of N integers, find the longest leading fragment of array which contains equal no. of X and Y. Expected time complexity is O(n).

• There’re 3 kinds of bus ticket. 1: ticket 1 cost 2 and can be used for a day. 2: ticket 2 cost 7 and can be used for a consecutive 7 days. 3: ticket 3 cost 25 can be used for a month. Assume month here means 30 consecutive days.

Now there’s a array filled with elements. Each element value is a date for a person to travel. This array has already been sorted in ascending order, like {1,3,4,5,11,12,23,24,30}. Obviously the final day is 30th and first day is 1st.

So for any given array from a person to travel, how can this person cost least ?

• Given N rows of seats in a movie theater, each row with seats labeled A to K some seats are reserved. A 3 person family want seats next to each other (seats across aisle is not allowed), return all available options.

Reserved seat will be given like “1A 2B 40G”.

• Design a class to calculate moving average of last N numbers in a stream of real numbers.

• Format a string of numbers to display a currency – example” “1234.678” to “1,234.68”.

• Given an array find the next greater element.

• Find the distance between any two nodes of the tree.

Technical Interview Questions
Data Structures and Algorithms

• Minimum Element in Stack.
• Top view of tree.
• Flip the ith bit without using ~.
• Queue using two stacks.
• Right view of a binary search tree.
• Find out the last nth node in a linked list.
• Write code for column wise tree traversal.
• Reverse a sentence of words.
• How do you check that a given binary tree is a valid balanced binary search tree?
• You receive a bit stream (0 and 1). Continuously receive a stream of bit, each time, you have to determine whether the current value is divisibility by 3 and print True or False.

DBMS

• DB Concurrency.

Miscellaneous

• What is the use of join() and yield() in Thread.
• What is a singleton class and how to protect it from reflection?
• Explain JVM architecture.
• What is Stack Frame ?