Saturday, December 19, 2015

Amazon Interview Experience

Round1 (Written)

1. Find the maximum element in an array which is first increasing and then decreasing. Time Complexity should be less than O(n).

http://www.geeksforgeeks.org/find-the-maximum-element-in-an-array-which-is-first-increasing-and-then-decreasing/

2.  Given an expression in string, check for balanced parenthesis.
http://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/

3. Find the level in binary tree which has maximum no of nodes. Print no of nodes and level.

Round2 (Face to Face)
1.  Print a binary tree in vertical order.
http://www.geeksforgeeks.org/print-binary-tree-vertical-order/

2. Search for an element in rotated and sorted array
http://www.geeksforgeeks.org/search-an-element-in-a-sorted-and-pivoted-array/

Round3 (Face to Face)

Design for scheduling jobs in distributed system. Give all the apis which will be exposed to user .
What all components will be involved at the backend. What data structures will be used etc.


Round4 (Face to Face)
1. Given a matrix with each cell containing no. of gold coins and a constraint that you can only move right or down from the top left corner to bottom right corner, find the path that gives you maximum gold coins and maximum no of gold coins that can be collected. (Dynamic Programming)

2. There are trillions of stars in sky and you are given distance of each start from the earth. You have to find million stars with least distance form the earth.

3.  There are n conference rooms and all are booked for a particular interval of time.
Let's say there are 3 rooms and their time slot of booking are:
Room1: {1,3} {6,7}, {8,9}
Room2: {2,5}, {9,10}
Room 3: {3,7}

Find the total no of hours in which all the rooms are unoccupied.
For above case, if we consider total no of hours as 20, all rooms are vacant for (20-8)=12 hours.
Solution:
1. Sort all the intervals based on start time.
2. Merge all overlapping interval
3. Find total no of hours covered by those intervals.
4. Subtract from total hour and return.

4. There are n workers and their wages are given for each day. If a worker work on day 1, he can only work after 3rd day. If he works on 3rd day, he can work after 5th day. Choose the day in such a way that he can maximize profit.
For ex: wages[] ={5, 1, 1, 10, 8, 3,5,12}
Maximum profit here is (5+10+12)=27  (Dynamic programming question)
http://ideone.com/ELwiJa

Round5 (Face to Face)
Manager Round
1. Find kth non repeating element in in stream of integers.
2.  Merge 2 sorted array to get sorted result array.
3. You are given an array whose each element represent height of the array. The width of every tower is 1. It starts raining. How much water is collected between the towers?
Ex: [1,3,5,7,2] = answer is 2 units between 5 and 7
4. You are having a conflict with your manager regarding how to prioritize your task . How would you convince him?
5. What is the biggest technical goof up you had lately?
6. What are you passionate about?








Monday, November 30, 2015

LinkedIn Interview Experience

Round 1 (Telephonic)
Data Structure

1.  Write code to find maximum contiguous sum in an array of integers.
2.  Write code to find maximum contiguous product in an array of integers.
3.  Given a nested listed of integers, return the sum of all integers reverse weighted by their depth.
     When I started taking time for it, question was simplified to find weighted by their depth.
     For ex: {{1,1}, 2, {1,1}} should return (1*2+1*2) + (2*1) + (1*2+1*2) = 10

Round 2 
Whiteboard Coding Round

1. Given a list of tuples representing intervals, return the range these intervals covered.
For ex: [1,3], [2,5], [8,9] should return 5.

2.  There is a list of Points given , let's say:
     {0,3}, {0,6}, {0,9}, {1, 8}, {1,5} . Find out 3 points whose distance is minimum from a given Point P {1,3}. Focus was to optimize on time complexity.

Round 3 
Whiteboard Coding Round

1. Find out maximum no of collinear points in a plane. Also find out the line formed by them.

Round 4
Design Round

1.  There is a set of let's say 10 servers which are receiving thousands of client request per second.
There is a function given isMalicious( String ip) which returns true of an ip is malicious.
Server should drop the ip if it is malicious.  Design such a system so that call to function isMalicious() is minimum.

Round 5
Host Manager Round

1. Tell me about yourself
2. Describe about the current project and various question on it like what were the challenges faced etc.
3. What are the steps that you will follow if you are assigned some task.

Round 6
Technical Communication

1. Talk about any interesting project that you have done in your career.
2. Lots of questions on project like how it will work in multithreaded environment, why certain design or technology was adopted. Could we have done something better ? etc. etc.






Snapdeal Interview for SSE

Round 1
Data Structure

1.  Given a column title as it appears in excel sheet, find the column no pertaining to that.
For ex. A -> 1
             B ->2
             AA -> 27 etc.

2.  Given a list of words. Find if two words can be joined to form a palindrome.

3.  You have 3 data points: Date, City, temperature. You can preprocess the data and keep it so that following query can be returned immediately.
  1) on 9th November, what was the temperature of Bangalore
   2) on 9th November, Give 5 hottest or coldest cities name.

Round 2
Java

1. Design elevator system along with UML diagram.
2. What is singleton and write singleton pattern.
3. Questions on other design patterns like decorator, strategy , builder etc.
4) What is advantage of using SPRING and REST etc.

Round 3
Hiring Manager

1. Why Snapdeal and what type of work excites me?
2. Where do you see yourself in next 5 years?
3. You have two classes. 1. Registry service 2. Client class and single JVM
Design a class in such a way that all the client classes register themselves to registry service when they are loaded.



Ola Interview for SDE II

               
Round 1
Machine Coding Round

Design Bowling game and write Java code for it using OOPS concept. Focus was on to check coding skills and design pattern being used.

Round 2
(Data Structure + Java Round)

1.  Rotate an array k times

2.  Reverse a linked list
http://www.geeksforgeeks.org/write-a-function-to-reverse-the-nodes-of-a-linked-list/

3. Level Order Traversal of a Tree
http://www.geeksforgeeks.org/level-order-tree-traversal/

4. Spiral Order Traversal of a tree
http://www.geeksforgeeks.org/level-order-traversal-in-spiral-form/

5. What is singleton pattern and write a singleton class

6. Why is singleton preferred over static class


Round 3
(Data Structure + Design Round)

 1. Given a binary tree in which each node contains a number. Find maximum possible sum from one leaf to another.
http://www.geeksforgeeks.org/find-maximum-path-sum-in-a-binary-tree/

2.  Lots of other technical questions like how to calculate shortest path b/w 2 Nodes etc.


Round 4
Hiring Manager Round

1. Lots of questions related to project and why certain technique was used.

2. There is a online shopping site which is receiving multiple requests at any point of time.
Design your system in way so that 
a) 10% of Requests are shown discount coupon "ABC"
b) 25% of Requests are shown discount coupon "MNO"
c) 65% of Requests are shown discount coupon "XYZ"