Hike interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Hike
upvote
share-icon
2 rounds | 4 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, Algorithms, System Design, OS, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Face to Face
Duration60 minutes
Interview date21 May 2015
Coding problem2

Technical interview round with questions based on DSA.

1. Tree Traversals

Easy
15m average time
85% success
0/40
Asked in companies
Wells FargoBig BasketMicrosoft

You have been given a Binary Tree of 'N'

nodes, where the nodes have integer values.


Your task is to return the ln-Order, Pre-Order, and Post-Order traversals of the given binary tree.


For example :
For the given binary tree:

Binary - Tree1

The Inorder traversal will be [5, 3, 2, 1, 7, 4, 6].
The Preorder traversal will be [1, 3, 5, 2, 4, 7, 6].
The Postorder traversal will be [5, 2, 3, 7, 6, 4, 1].
Problem approach

Inorder traversal requires that we print the leftmost node first and the right most node at the end. 
So basically for each node we need to go as far as down and left as possible and then we need to come back and go right. So the steps would be : 
1.Start with the root node. 
2. Push the node in the stack and visit it's left child.
3. Repeat step 2 while node is not NULL, if it's NULL then pop the topmost node from the stack and print it.
4. Now move to node's right child and repeat step 1
5. Repeat the above steps while node is not NULL and stack is not empty

Try solving now

2. LRU Cache Implementation

Moderate
25m average time
65% success
0/80
Asked in companies
MicrosoftUberSalesforce

Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:

1. get(key) - Return the value of the key if the key exists in the cache, otherwise return -1.

2. put(key, value), Insert the value in the cache if the key is not already present or update the value of the given key if the key is already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting the new item.
You will be given ‘Q’ queries. Each query will belong to one of these two types:
Type 0: for get(key) operation.
Type 1: for put(key, value) operation.
Note :
1. The cache is initialized with a capacity (the maximum number of unique keys it can hold at a time).

2. Access to an item or key is defined as a get or a put operation on the key. The least recently used key is the one with the oldest access time.
Problem approach

Structure of an LRU Cache :

1) In practice, LRU cache is a kind of Queue — if an element is re accessed, it goes to the end of the eviction order
2) This queue will have a specific capacity as the cache has a limited size. Whenever a new element is brought in, it is added at the head of the queue. When eviction happens, it happens from the tail of the queue.
3) Hitting data in the cache must be done in constant time, which isn't possible in Queue! But, it is possible with HashMap data structure
4) Removal of the least recently used element must be done in constant time, which means for the implementation of Queue, we'll use DoublyLinkedList instead of SingleLinkedList or an array.

LRU Algorithm :

The LRU algorithm is pretty easy! If the key is present in HashMap, it's a cache hit; else, it's a cache miss.

We'll follow two steps after a cache miss occurs:

1) Add a new element in front of the list.
2) Add a new entry in HashMap and refer to the head of the list.

And, we'll do two steps after a cache hit:

1) Remove the hit element and add it in front of the list.
2) Update HashMap with a new reference to the front of the list.

Tip : This is a very frequently asked question in interview and its implementation also gets quite cumbersome if you are doing it for the first time so better knock this question off before your SDE-interviews.

Try solving now
02
Round
Medium
Face to Face
Duration60 minutes
Interview date21 May 2015
Coding problem2

Technical Interview round with questions on DSA, OS etc.

1. Number of Islands II

Hard
45m average time
55% success
0/120
Asked in companies
MicrosoftAmazonHike

You have a 2D grid of ‘N’ rows and ‘M’ columns which are initially filled with water. You are given ‘Q’ queries each consisting of two integers ‘X’ and ‘Y’ and in each query operation, you have to turn the water at position (‘X’, ‘Y’) into a land. You are supposed to find the number of islands in the grid after each query.

An island is a group of lands surrounded by water horizontally, vertically, or diagonally.

Problem approach

The idea here is to represent the grid as a graph and all the adjacent land cells are connected via an edge. Finally, do DFS on the grid and find the number of connected components after each query operation.

 

The algorithm is as follows:

  1. Declare an ‘ANS’ array to store the number of islands after each query.
  2. Declare a 2D array 'GRID' with ‘N’ rows and ‘M’ columns, where ‘GRID[i][j]’ = 0 or 1, 0 representing water and 1 representing land.
  3. Declare a ‘DX’ array representing and set it to {1, 0, -1, 0}, representing the directions of all four neighboring cells.
  4. Declare a ‘DY’ array representing and set it to {0, 1, 0, -1}, representing the directions of all four neighboring cells.
  5. Iterate from ‘P’ = 0 to ‘Q.size() - 1’,
    • Declare a variable ‘X’ and set it to ‘Q[i][0]’.
    • Declare a variable ‘Y’ and set it to 'Q[i][1]'.
    • Set ‘GRID[X][Y]’ to 1, i.e i.e cell is converted into the land.
    • Declare a variable 'NUMBEROFISLANDS' and set it to 0.
    • Declare a 2D array ‘VISITED’ with ‘N’ rows and ‘M’ columns, where ‘VISITED[i][j]’ = 0 or 1, 0 representing the current cell being visited and 1 representing not visited.
    • Iterate from ‘i’ = 0 to ‘N’ - 1,
      • Iterate from ‘j’ = 0 toM’ - 1,
        • If ‘GRID[i][j]’ == 1 && ‘VISITED[i][j]’ == 0,
          • This means the current cell is an island that is not seen before.
          • Run a ‘DFS’ function and mark all the connected lands as ‘VISITED’ that are connected to the cell (i,j).
          • Increment 'NUMBEROFISLANDS' by 1.
    • Append 'NUMBEROFISLANDS' to ‘ANS’.
  6. Return the ‘ANS’ array.
Try solving now

2. OOPS Question

Why are synchronised blocks needed in Java?

Problem approach

A Java synchronized block marks a method or a block of code as synchronized. A synchronized block in Java can only be executed a single thread at a time (depending on how you use it). Java synchronized blocks can thus be used to avoid race conditions.
Synchronization is needed for objects, which are shared among multiple threads, to avoid any corruption of state or any kind of unexpected behavior. Synchronization in Java will only be needed if shared object is mutable.
It helps in concurrent programming. The synchronized keyword in Java provides locking, which ensures mutually exclusive access to the shared resource and prevents data race.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Hike
932 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 3 problems
Interviewed by Hike
1069 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 5 problems
Interviewed by Hike
834 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 3 problems
Interviewed by Hike
294 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115097 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58238 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35147 views
7 comments
0 upvotes