Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Samsung interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Samsung
upvote
share-icon
4 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures and Algorithms, OOPS, DBMS, Operating Systems, Dynamic Programming
Tip
Tip

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.

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

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.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration180 minutes
Interview date29 Aug 2018
Coding problem1

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.

1. Check Bipartite Graph

Moderate
50m average time
50% success
0/80
Asked in companies
UberWalmarteBay

Given a graph, check whether the graph is bipartite or not. Your function should return true if the given graph's vertices can be divided into two independent sets, ‘U’ and ‘V’ such that every edge (‘u’, ‘v’) either connects a vertex from ‘U’ to ‘V’ or a vertex from ‘V’ to ‘U’.

You are given a 2D array ‘edges’ which contains 0 and 1, where ‘edges[i][j]’ = 1 denotes a bi-directional edge from ‘i’ to ‘j’.

Note:
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’.

For example

Given:
‘N’ = 3
‘edges’ = [[0, 1, 1], [0, 0, 1], [0,0,0]]. 

Problem approach

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.

Try solving now
02
Round
Medium
Face to Face
Duration30 minutes
Interview date4 Sep 2018
Coding problem3

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. Implement stack using queue

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

Implement a Stack Data Structure specifically to store integer data using two Queues.


There should be two data members, both being Queues to store the data internally. You may use the inbuilt Queue.


Implement the following public functions :

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.
Operations Performed on the Stack:
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)
Example
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]
Problem approach

It was a pretty straightforward question.

Try solving now

2. Rain Water Trapping problem

Moderate
15m average time
80% success
0/80
Asked in companies
GoogleGrabSAP Labs

You have been given a long type array/list 'arr’ of size 'n’.


It represents an elevation map wherein 'arr[i]’ denotes the elevation of the 'ith' bar.



Note :
The width of each bar is the same and is equal to 1.
Example:
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].

Output: 10

Explanation: Refer to the image for better comprehension:

Alt Text

Note :
You don't need to print anything. It has already been taken care of. Just implement the given function.
Problem approach

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.

Try solving now

3. Implement queue using stack

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

Implement a Stack Data Structure specifically to store integer data using two Queues.


There should be two data members, both being Queues to store the data internally. You may use the inbuilt Queue.


Implement the following public functions :

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.
Operations Performed on the Stack:
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)
Example
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]
Problem approach

It was a pretty straightforward question.

Try solving now
03
Round
Medium
Face to Face
Duration30 minutes
Interview date4 Sep 2018
Coding problem3

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. Maximum amount of gold collected from gold mine

Moderate
35m average time
70% success
0/80
Asked in companies
SamsungTata Consultancy Services (TCS)Goldman Sachs

You have been given a gold mine represented by a 2-d matrix of size ('N' * 'M') 'N' rows and 'M' columns. Each field/cell in this mine contains a positive integer, the amount of gold in kgs.

Initially, the miner is at the first column but can be at any row.

He can move only right, right up, or right down. That is from a given cell and the miner can move to the cell diagonally up towards the right or right or diagonally down towards the right.

Find out the maximum amount of gold he can collect.

Problem approach

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.

Try solving now

2. Rod Cutting problem

Moderate
40m average time
75% success
0/80
Asked in companies
SamsungRazorpayPaytm (One97 Communications Limited)

Given a rod of length ‘N’ units. The rod can be cut into different sizes and each size has a cost associated with it. Determine the maximum cost obtained by cutting the rod and selling its pieces.

Note:
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.
Problem approach

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.

Try solving now

3. Theory Question

Explain Convoy effect and Belady's anomaly.

Problem approach

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.
 

04
Round
Easy
HR Round
Duration15 minutes
Interview date4 Sep 2018
Coding problem1

Interviewer was friendly. 

1. HR Questions

He asked why do you want to join Samsung? 

Are you comfortable relocating to Bangalore?

Also asked about my experience in previous rounds.

Problem approach

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?

Start a Discussion
Similar interview experiences
company logo
SDE - 1
4 rounds | 6 problems
Interviewed by Samsung
1120 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by Samsung
1589 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 3 problems
Interviewed by Samsung
1016 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by Samsung
95 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
104062 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
49378 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
30808 views
6 comments
0 upvotes