Tip 1 : Do practice a lot of coding problems specially Dynamic Programming. I pursued Coding Ninjas Interview preparation Course for cracking the interviews. Also prepared for DBMS, Operating systems and OOPS from Coding Ninjas notes.
Tip 2 : Always start with Brute force approach and then try to optimize it. Practice problems on paper more.
Tip 3 :Be confident during the interview and interact with the interviewer.
Tip 1:Keep your Resume short and crisp, in 1 Page. Have a complete understanding of the Projects mentioned in your resume.
Tip 2:Your interview always revolves around your resume. Go through it thoroughly before the interview.
In this round, you have to do a coding question on Samsung Coding Platform, which was installed earlier on our lab's system by the company guys. There is only a single question and time limit is of 3 hrs. There are 50 test cases, and you have to pass all the test cases in order to get selected for next round. Also you cannot use any inbuilt library and you have to implement everything from scratch (like stack, queue, hashmap, etc). You can test your code on sample test cases multiple times but the submission limit in only 5, to test the hidden test cases.
Note : Even passing 49 test cases will lead to rejection.
If edges[i][j] = 1, that implies there is a bi-directional edge between ‘i’ and ‘j’, that means there exists both edges from ‘i’ to ‘j’ and to ‘j’ to ‘i’.
Given:
‘N’ = 3
‘edges’ = [[0, 1, 1], [0, 0, 1], [0,0,0]].
1. Used BFS to solve the problem.
2. Implemented queue with the help of a class.
3. Did a BFS traversal of the given points using queue and kept assigning them colors accordingly.
4. Assign RED color to the source vertex.
5. Color all the neighbors with BLUE color.
6. Color all neighbor’s neighbor with RED color.
7. This way, assign color to all vertices.
8. While assigning colors, if we find a neighbor which is colored with same color as current vertex, then the graph is not Bipartite.
4. Also maintained a boolean array to keep the track of visited nodes.
There were two questions based on data structures and algorithms and some discussion on the Projects mentioned in resume (Major Project based on Arduino - It's programming and its functionality) .
1. Constructor:
It initializes the data members(queues) as required.
2. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.
3. pop() :
It pops the element from the top of the stack and, in turn, returns the element being popped or deleted. In case the stack is empty, it returns -1.
4. top :
It returns the element being kept at the top of the stack. In case the stack is empty, it returns -1.
5. size() :
It returns the size of the stack at any given instance of time.
6. isEmpty() :
It returns a boolean value indicating whether the stack is empty or not.
Query-1(Denoted by an integer 1): Pushes an integer data to the stack. (push function)
Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack and returns it to the caller. (pop function)
Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack but doesn't remove it, unlike the pop function. (top function)
Query-4(Denoted by an integer 4): Returns the current size of the stack. (size function)
Query-5(Denoted by an integer 5): Returns a boolean value denoting whether the stack is empty or not. (isEmpty function)
Operations:
1 5
1 10
2
3
4
Enqueue operation 1 5: We insert 5 at the back of the queue.
Queue: [5]
Enqueue operation 1 10: We insert 10 at the back of the queue.
Queue: [5, 10]
Dequeue operation 2: We remove the element from the front of the queue, which is 5, and print it.
Output: 5
Queue: [10]
Peek operation 3: We return the element present at the front of the queue, which is 10, without removing it.
Output: 10
Queue: [10]
IsEmpty operation 4: We check if the queue is empty.
Output: False
Queue: [10]
It was a pretty straightforward question.
The width of each bar is the same and is equal to 1.
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].
Output: 10
Explanation: Refer to the image for better comprehension:
You don't need to print anything. It has already been taken care of. Just implement the given function.
Firstly tried using Brute force approach.
Then I was asked to optimize the space complexity and do it in O(1) space comlpexity.
Was able to code on paper in time.
1. Constructor:
It initializes the data members(queues) as required.
2. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.
3. pop() :
It pops the element from the top of the stack and, in turn, returns the element being popped or deleted. In case the stack is empty, it returns -1.
4. top :
It returns the element being kept at the top of the stack. In case the stack is empty, it returns -1.
5. size() :
It returns the size of the stack at any given instance of time.
6. isEmpty() :
It returns a boolean value indicating whether the stack is empty or not.
Query-1(Denoted by an integer 1): Pushes an integer data to the stack. (push function)
Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack and returns it to the caller. (pop function)
Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack but doesn't remove it, unlike the pop function. (top function)
Query-4(Denoted by an integer 4): Returns the current size of the stack. (size function)
Query-5(Denoted by an integer 5): Returns a boolean value denoting whether the stack is empty or not. (isEmpty function)
Operations:
1 5
1 10
2
3
4
Enqueue operation 1 5: We insert 5 at the back of the queue.
Queue: [5]
Enqueue operation 1 10: We insert 10 at the back of the queue.
Queue: [5, 10]
Dequeue operation 2: We remove the element from the front of the queue, which is 5, and print it.
Output: 5
Queue: [10]
Peek operation 3: We return the element present at the front of the queue, which is 10, without removing it.
Output: 10
Queue: [10]
IsEmpty operation 4: We check if the queue is empty.
Output: False
Queue: [10]
It was a pretty straightforward question.
There were two coding questions and I had to write the code on paper.
After that there was a discussion on OOPS concepts like polymorphism and Inheritance.
The interviewer also discussed about padding concept in structures (Indirectly via an example).
1. Create a 2-D matrix goldTable[][]) of the same as given matrix mat[][].
2. Amount of gold is positive, so we would like to cover maximum cells of maximum values under given constraints.
In every move, we move one step toward right side. So we always end up in last column. If we are at the last column, then we are unable to move right.
3. If we are at the first row or last column, then we are unable to move right-up so just assign 0 otherwise assign the value of goldTable[row-1][col+1] to right_up.
4. If we are at the last row or last column, then we are unable to move right down so just assign 0 otherwise assign the value of goldTable[row+1][col+1] to right up.
5. Now find the maximum of right, right_up, and right_down and then add it with that mat[row][col]. At last, find the maximum of all rows and first column and return it.
1. The sizes will range from 1 to ‘N’ and will be integers.
2. The sum of the pieces cut should be equal to ‘N’.
3. Consider 1-based indexing.
First I tried to solve using recursive approach by considering all the possible combinations. Interviewer asked to optimize the solution as the time complexity was exponential.
I observed that we can store the previous answers in an array. Thus I was able to solve the problem using an extra array using dynamic programming concept. I was asked to write the optimized code on paper.
Explain Convoy effect and Belady's anomaly.
Tip 1: Prepared for the subjective concepts from Coding Ninjas Notes.
Tip 2: Always try to explain the interviewer with the help of an example.
Interviewer was friendly.
He asked why do you want to join Samsung?
Are you comfortable relocating to Bangalore?
Also asked about my experience in previous rounds.
Tip 1: Be confident.
Tip 2: Always involve in interaction with the interviewer. Do ask about the company's work culture and related stuff. This shows him that you are interested for the role.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What does ROLLBACK do in DBMS?