Tip 1 : Focus on DSA as you will be judged mostly on that for entry-level software engineer profiles.
Tip 2 : Don't mug up the solution as you might not be able to recall the approach or you might face new question that you haven't seen earlier.
Tip 3 : Practice as much as possible from platforms like InterviewBit, LeetCode.
Tip 1 : Try not to mention those things about which you are not comfortable.
Tip 2 : Having one or two good projects in resume helps.
Tip 3 : Mention good competitive programming ranks (if any)
Tip 4 : Use overleaf.com for making a resume using Latex.
Right rotation on a matrix is shifting each column to the right side (the last column moves to the first column) and 'K' times means performing this rotation 'K' times.
For 'K' = 1 and the given 'MAT':
1 2 3
4 5 6
7 8 9
Output after rotating 'MAT' one time is:
3 1 2
6 4 5
9 7 8
There are three occurrences of the word 'NINJA' in the following grid:
1) Given word will not be a single character.
2) If occurrences of the given word start from two different cells, then these two occurrences are considered to be different.
Consider the word 'XYX' to be searched in the string 'AXYXB'. Here, we find an occurrence of 'XYX' at index 2 going in the right direction, and another occurrence at index 4 going in the left direction.
Although these two words correspond to the same word, they will be considered as different occurrences.
1. Coded using recursion and backtracking but the time complexity was of exponential order so time limit exceeded.
2. Tried to code it using DFS but couldn't code it in the given time.
Interview started with an introduction and walk through the resume for first 5 minutes. After that, interview asked few coding questions.
Input: 'n' = 3, 'm' = 4
'queries' = [[1, 1], [1, 2], [2, 3]]
Output: [1, 1, 2]
Explanation:
Initially, the grid was:
0 0 0 0
0 0 0 0
0 0 0 0
After query (1, 1):
0 0 0 0
0 1 0 0
0 0 0 0
There is one island having land (1, 1).
After query (1, 2):
0 0 0 0
0 1 1 0
0 0 0 0
Since (1, 1) and (1, 2) share a common edge, they form one island. So there is one island having lands (1, 1) and (1, 2).
After query (2, 3):
0 0 0 0
0 1 1 0
0 0 0 1
Now there are two islands, one having lands (1, 1) and (1, 2), and another having land (2, 3).
So the number of islands after each query is [1, 1, 2].
1. I was little stuck in stuck in start but later on came up with DFS approach.
2. Interviewer was satisfied the approach and asked me to code it.
1. Told the brute force which is to traverse the whole matrix.
2. Optimized it using binary search on each row. But interviewer want more optimized approach than this.
3. After thinking for few minutes, came up with the approach of starting from top right and take decision whether to go left or down depending on the element in left. Interviewer asked me to further optimize.
4. Optimized it by using combination of 3rd approach and binary search. After that, interviewer asked me to code it.
1. The integers x,y and z might not be distinct , but they should be present at different locations in the array i.e if a[i] = x, a[j] = y and a[k] = z, then i,j and k should be pairwise distinct.
2. The integers a,b and c can be present in any order in the given array.
Input: Let the binary tree be:
Output: [10, 4, 2, 1, 3, 6]
Explanation: Consider the vertical lines in the figure. The top view contains the topmost node from each vertical line.
This round was focused on DSA along with short discussion on computer science fundamentals. For coding problems, I was asked to code the first problem only. For others, had to discuss the approach only. For computer science fundamentals, discussion on OOPS. Differences between process and threads were discussed.
Given BST will not contain duplicates.
A Binary Search Tree (BST) whose 2 nodes have been swapped is shown below.
After swapping the incorrect nodes:
Can you do this without using any extra space?
After getting some of the hints, was able to come up with in-order traversal approach which takes extra space. Interviewer wanted better approach without extra space. But couldn't think of it.
getSize: Returns an integer. Gets the current size of the stack
isEmpty: Returns a boolean. Gets whether the stack is empty
push: Returns nothing. Accepts an integer. Puts that integer at the top of the stack
pop: Returns nothing. Removes the top element of the stack. It does nothing if the stack is empty.
getTop: Returns an integer. Gets the top element of the stack. Returns -1 if the stack is empty
1. Told the approach using hashmap.
2. Optimized it further by using tries.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL keyword removes duplicate records from a result set?