## Samsung Interview Questions

- 0of 0 votes

AnswerHow to divide a circular array into k group of contiguous element such that difference between maximum sum and minimum sum is minimum. Each group have contiguous element of array. For e.g If the array is as follow. [6 13 10 2] and k=2 then o/p should be 18(6+10+2)-13=5. As array is circular 6,10,2 are contiguous element of array.

- Himanshu Singh January 05, 2019 in India

For e.g If the array is as follow. [6 13 2 10] and k=2 then o/p should be 16(6+10)-15(13+2)=1. As array is circular 6,10 are contiguous element of array.

For e.g If the array is as follow. [100 92 133 201 34 34 34 94 108] and k=4 then group as follow 208(108,100), 225(92,133), (201), 196(34,34,34,94) so 225-196=29| Report Duplicate | Flag | PURGE

Samsung Software Developer Algorithm - 0of 0 votes

AnswersThere are N nodes in a graph connected by exactly N-1 edges. There is exactly 1 shortest path from one node to any other node. The nodes are numbered from 1 to N. Given Q queries which tell source node and the destination nodes. Find the most visited node after traveling those Q paths. For example, say Q=3

- sudhiammula November 23, 2018 in India

and 3 queries are

1 5

2 4

3 1

So travel from node 1 to node 5, then from node 2 to node 4, then from node 3 to node 1. Finally, find what is the most visited node after the Q queries.

Finding every path and incrementing every visited node count is a naive solution. The interviewer asked me to optimize it.| Report Duplicate | Flag | PURGE

Samsung SDE1 Trees and Graphs - 0of 0 votes

AnswersIt was a online coding round on software provided by samsung itself.

- @nnonymous October 07, 2018 in India

Given a graph print either of the set of the vertices that are colored with the same color. And if the graph is not bipartite print “-1”. Test cases also included the cases when a graph is not connected.

Note: No STL or other library functions were allowed| Report Duplicate | Flag | PURGE

Samsung Software Engineer Coding - 0of 0 votes

Answersfind the sum of bit wise OR of minimum and Maximum element of all the subsets whose length is greater than 2 of the given of set.

- MukeshGupta0315 May 20, 2018 in India

for ex:-

{1,2,3} is set

then possible subsets of length is{ 1,2},{1,3},{2,3}{1,2,3} answer 1|2 +1|3 +2|3 +1|3=12| Report Duplicate | Flag | PURGE

Samsung Software Engineer Java - 0of 0 votes

AnswerSearch for a sorted integer in an integer array that has been rotated multiple times.

- teli.vaibhav May 14, 2018 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 1of 1 vote

AnswersPrint the bottom view of a Binary Tree.

ex-`1 2 3 4 5 7 8 9 10`

result is 4, 8, 5, 9, 7, 10

- teli.vaibhav May 14, 2018 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 0of 0 votes

AnswerYou are given the length and time of occurrence of packet and Queues which process packets. Total processing time for a packet is equal to the length of packet plus the waiting time in queue. For eg lets say we have only one queue for now, and A packet of length 5 comes at t = 1, and another packet of length 4 comes at t = 3. Total processing time for first packet is 5( no waiting time as queue is empty at t = 1) and at t = 3, 2 units of first packet is processed and 3 units remaining so, for second packet 3 units will be waiting time in queue plus 4 units for its length. Total processing time for 2nd packet is 7 units. If there are multiple queues you can add new packet in any of the other queues. Given the time and length of all incoming packets, we need to find the minimum no. of queues required such that total processing time of each packet is less than 10 units. Maximum possible no. of queues are 5. If you require more than 5 queues print -1.

Test Cases Format: First Line contains the number N, the total no. of packets and N following line contains two numbers ti, li where li is length of packet coming at time = ti units.

Test case1:

2

2 7

5 8

Test Case 2:

3

1 3

2 3

3 5

Test Case 3:

3

1 5

2 4

3 8

Output:

Case1: 2

Case2: 1

Case3: 2

Consider the following time table of incoming packets:`time packets-length 1 8 2 5 3 2 4 6`

If you put the packet in queue with minimum time then this will lead to 3 queues:

- ak4017 April 25, 2018 in United States

t = 1:

q1: 8

t = 2:

q1: 7

q2: 5

t = 3:

q1: 6

q2: 4, 2

t = 4:

q1: 5

q2: 3, 2

q3: 6

But its output should be 2 queues:

1) 8 in queue 1

2) 5 in queue 2

3) 2 in queue 1

4) 6 in queue 2| Report Duplicate | Flag | PURGE

Samsung Software Developer Algorithm - 0of 0 votes

Answersgiven an array of integers suppose 1234, print all groups of integer array possible of length upto n where n can be any number greater than zero

- mohapatrasandeep60 March 05, 2018 in India

example for n=5

1,11,111,1111,11111,12341,22222,2222,222,22,2 etc

for n=3

1,11,123 etc| Report Duplicate | Flag | PURGE

Samsung Developer Program Engineer - 1of 1 vote

AnswersCompany S has developed an industrial endoscope available to explore inner part of the decrepit water pipes. It is possible to explore the inner part of the pipes putting the endoscope in a certain part of the pipe. The endoscope can be moved in the pipe only. Meanwhile, when the pipes are connected to each other, if the length of the endoscope is long enough to explore ,then it is able to inspect the connected pipes. However, we cannot observe every pipe because the length of endoscope is limited.

- Jubayer February 07, 2018 in India

When the map of the ground water pipe, the location where the endoscope to out in, and the length of the endoscope is given, calculate the number of pipe which are available to explore. Length of endoscope means the range upto which endoscope can explore. There are seven kind of pipes, and description for each pipe are shown below:

S.No Pipe Connected to

1 Up, Down, Left, Right

2 Up, Down

3 Left, Right

4 Up, Right

5 Down, Right

6 Down, Left

7 Up, Left

When the map of the ground water pipe, the location where the endoscope to out in, and the length of the endoscope is given, calculate the number of pipe which are available to explore. Length of endoscope means the range upto which endoscope can explore.

Input

In the first line, T, the number of total test cases is given. From the second line, T test cases are given. In the first line of each test case, N, the height of the map of the ground water pipes, M, the width, R, the vertical location of the water pipe where to put in the endoscope, C, the horizontal location of it, and the length of the endoscope L are given. In the following N lines information of the map of ground water pipe is given. Each line has M numbers. Each number (from 1 to 7) means the type of water pipe for that point. 0 means there is no water pipe buried in that place.

Output

Print the respective answer for T test cases in total for T lines. The answer is the number of water pipes which is available to observe using the endoscope.

Constraints

1≤ T ≤100

1≤ N, M ≤50

0≤ X < N

0≤ Y < M

1≤ L ≤ 20| Report Duplicate | Flag | PURGE

Samsung freshers - 0of 0 votes

AnswerA Research team want to establish a research center in a region where they found some rare-elements. They want to make it closest to all the rare-elements as close as possible so that they can reduce overall cost of research over there. It is given that all the rare-element’s location is connected by roads. It is also given that Research Center can only be build on road. Team decided to assign this task to a coder. If you feel you have that much potential..

- Jubayer February 01, 2018 in India

Here is the Task :- Find the shortest of the longest distance of research center from given locations of rare-elements.

Locations are given in the matrix cell form where 1 represents roads and 0 no road..

Number of rare-element and their location was also given(number<=5)

and order of square matrix was less than equal to (20).| Report Duplicate | Flag | PURGE

Samsung Software Engineer / Developer - 0of 0 votes

AnswersGiven number of pipes 1..n, Find two largest pipes of maximum length possible.

- NoName December 12, 2017 in India

Ex: input - 1,2,3,4,6

Output - The maximum length possible is 8.

Pipe1 - 2,6

Pipe2 - 1,3,4| Report Duplicate | Flag | PURGE

Samsung None - -2of 2 votes

AnswersThere was given total physical energy H and total distance D. Five pace information speed and corresponding physical energy was given. Find the minimum time that is required in order to complete total distance D making sure that some of the physical energy does not exceed H

- sonuanand2007 November 11, 2017 in India| Report Duplicate | Flag | PURGE

Samsung Software Developer - 1of 1 vote

AnswersThis was a 3 hours coding round in which we had to code 1 problem having 50 test cases. Only those students were selected for the next round who passed all the test cases. Here is the question:

- jatinbansal321 September 08, 2017 in India

You’ll be given a grid as below:

0 1 0 2 0

0 2 2 2 1

0 2 1 1 1

1 0 1 0 0

0 0 1 2 2

1 1 0 0 1

x x S x x

In the grid above,

1: This cell has a coin.

2: This cell has an enemy.

0: It contains nothing.

The highlighted(yellow) zone is the control zone. S is a spaceship that we need to control so that we can get maximum coins.

Now, S’s initial position will be at the center and we can only move it right or left by one cell or do not move.

At each time, the non-highlighted part of the grid will move down by one unit.

We can also use a bomb but only once. If we use that, all the enemies in the 5×5 region above the control zone will be killed.

If we use a bomb at the very beginning, the grid will look like this:

0 1 0 2 0

0 0 0 0 1

0 0 1 1 1

1 0 1 0 0

0 0 1 0 0

1 1 0 0 1

x x S x x

As soon as, the spaceship encounters an enemy or the entire grid has come down, the game ends.

For example,

At the very first instance, if we want to collect a coin we should move left( coins=1). This is because when the grid comes down by 1 unit we have a coin on the second position and by moving left we can collect that coin. Next, we should move right to collect another coin( coins=2).

After this, remain at the same position( coins=4).

This is the current situation after collecting 4 coins.

0 1 0 2 0 0 1 0 0 0

0 2 2 2 1 -->after using 0 0 0 0 1

x x S x x -->bomb x x S x x

Now, we can use the bomb to get out of this situation. After this, we can collect at most 1 coin. So maximum coins=5.| Report Duplicate | Flag | PURGE

Samsung Software Engineer - 2of 2 votes

AnswersYou are given an old touch smartphone numbers having dial pad and calculator app.

- neovivek14 July 23, 2017 in United States

Aim: The goal is to type a number on dialpad.

But as phone is old, some of the numbers and some operations can't be touched.

For eg. 2,3,5,9 keys are not responding , i.e you cannot use them

But you can always make a number using other numbers and operations in Calculator. There could be multiple ways of making a number

.Calculator have 1-9 and +,-,*,/,= as operations. Once you have made the number in Calculator you can copy the number and use it.

You have to find minimum number to touches required to obtain a number.

#Input:#

There will be multiple Test cases .Each test case will consist of 4 lines

1) First line will consist of N,M,O

N: no of keys working in Dialpad (out of 0,1,2,3,4,5,6,7,8,9)

M:types of operations supported (+,-,*,/)

O: Max no of touches allowed

2) second line of input contains the digits that are working e.g 0,2,3,4,6.

3) Third line contains the valued describing operations, 1(+),2(-),3(*),4(/)

4) fourth line contains the number that we want to make .

#Output:#

Output contains 1 line printing the number of touches required to make the number

#Sample Test Case:#

1 // No of test cases

5 3 5 // N ,M, O

1 2 4 6 0 // digits that are working (total number of digits = N),

1 2 3 // describing operations allowed (1--> '+', 2--> '-', 3--> '*' , 4--> '/' )(total number is equals to M)

5 // number we want to make

Answer 3

How 4? 1+4= , "=" is also counted as a touch

2nd Sample Case

3 // No of Test cases

6 4 5 // N ,M, O

1 2 4 6 9 8 // digits that are working (total number of digits = N),

1 2 3 4 // describing operations allowed (1--> +, 2--> -, 3--> , 4-->/)

91 // number we want to make

6 2 4 // 2nd test case

0 1 3 5 7 9

1 2 4 // +, -, / allowed here

28

5 2 10

1 2 6 7 8

2 3 // -, allowed

981

#Output:#

2 // 91 can be made by directly entering 91 as 1,9 digits are working, so only 2 operations

5// 35-7=, other ways are 1+3*7=

9//62*16-11=

Order for computation will be followed as symbols entered, if + comes, it will be computed first

One more example: lets say 1,4,6,7,8,9 works and +,-,* works.

2,3,5 and / doesn't work.

If you have to type 18-> 2 operations. (Each touch is considered an operation),br> If you have to type 5 -> '1+4=' that requires 4 operations. There could be other ways to make '5'.| Report Duplicate | Flag | PURGE

Samsung Software Engineer Algorithm - 0of 2 votes

AnswersThere is an island surrounded by oil mines. You will be given n companies and m oil mines having values. You have to distribute the mines to "n" companies in fair manner. Remember the companies can have oil mines adjacent to each other and not in between of each others.After distributing them compute the differnce of oil mines from the company getting highest and company getting lowest. This number should be minimum.(then only the distribution can be termed as fair).

- sunny.1rn12cs113 March 26, 2017 in India

Example

Input

2

2 4

6 13 10 2

2 4

6 10 13 2

output

5

1| Report Duplicate | Flag | PURGE

Samsung Java Developer Data Structures - 0of 0 votes

AnswersThere is dedicated Samsung software for coding test the question is given below:

- pbox February 09, 2017 in India

There is one spaceship. X and Y co-odinate of source of spaceship and destination spaceship is given. There are N number of warmholes each warmhole has 5 values.

First 2 values are starting co-ordinate of warmhole and after that value no. 3 and 4 represents ending co-ordinate of warmhole and last 5th value is represents cost to pass through this warmhole. Now these warmholes are bi-direction.

Now the to go from (x1,y1) to (x2,y2) is abs(x1-x2)+abs(y1-y2).

The main problem here is to find minimum distance to reach spaceship from source to destination co-ordinate using any number of warm-hole. It is ok if you wont use any warmhole.| Report Duplicate | Flag | PURGE

Samsung Software Engineer Algorithm - 2of 2 votes

AnswersMr. Kim has to deliver refrigerators to N customers. From the office, he is going to visit all the customers and then return to his home. Each location of the office, his home, and the customers is given in the form of integer coordinates (x,y) (0≤x≤100, 0≤y≤100) . The distance between two arbitrary locations (x1, y1) and (x2, y2) is computed by |x1-x2| + |y1-y2|, where |x| denotes the absolute value of x; for instance, |3|=|-3|=3. The locations of the office, his home, and the customers are all distinct. You should plan an optimal way to visit all the N customers and return to his among all the possibilities.

- Loser September 03, 2016 in India

You are given the locations of the office, Mr. Kim’s home, and the customers; the number of the customers is in the range of 5 to 10. Write a program that, starting at the office, finds a (the) shortest path visiting all the customers and returning to his home. Your program only have to report the distance of a (the) shortest path.

You don’t have to solve this problem efficiently. You could find an answer by looking up all the possible ways. If you can look up all the possibilities well, you will get a perfect score.

[Constraints]

5≤N≤10. Each location (x,y) is in a bounded grid, 0≤x≤100, 0≤y≤100, and x, y are integers.

[Input]

You are given 10 test cases. Each test case consists of two lines; the first line has N, the number of the customers, and the following line enumerates the locations of the office, Mr. Kim’s home, and the customers in sequence. Each location consists of the coordinates (x,y), which is reprensented by ‘x y’.

[Output]

Output the 10 answers in 10 lines. Each line outputs the distance of a (the) shortest path. Each line looks like ‘#x answer’ where x is the index of a test case. ‘#x’ and ‘answer’ are separated by a space.

[I/O Example]

Input (20 lines in total. In the first test case, the locations of the office and the home are (0, 0) and (100, 100) respectively, and the locations of the customers are (70, 40), (30, 10), (10, 5), (90, 70), (50, 20).)

5 ← Starting test case #1

0 0 100 100 70 40 30 10 10 5 90 70 50 20

6 ← Starting test case #2

88 81 85 80 19 22 31 15 27 29 30 10 20 26 5 14

10 ← Starting test case #3

39 9 97 61 35 93 62 64 96 39 36 36 9 59 59 96 61 7 64 43 43 58 1 36

...

Output (10 lines in total)

#1 200

#2 304

#3 366| Report Duplicate | Flag | PURGE

Samsung Software Engineer Algorithm - 1of 1 vote

AnswersYou are given an old touch smartphone numbers having dial pad and calculator app.

- tambimitesh22 July 01, 2016 in United States

The goal is to type a number on dialpad.

Calculator have 1-9 and +,-,*,/,= as operations. But as phone is old, some of the numbers and some operations can't be touched.

But you can always make a number using other numbers and operations. There could be multiple ways of making a number. You have to find minimum operation for making a number.

For ex: lets say 1,4,6,7,8,9 works and +,-,* works.

2,3,5 and / doesn't work.

If you have to type 18-> 2 operations. (Each touch is considered an operation)

If you have to type 5 -> '1+4=' that requires 4 operations. There could be other ways to make '5'.

The goal is to find minimum operations.| Report Duplicate | Flag | PURGE

Samsung SDE-2 Algorithm - 1of 1 vote

Answerthere is a file and 5 processes

- mohapatrasandeep60 February 04, 2016 in United States

how can you grant access so that

only 2 process can write to file and 1 can read file at a time

in linux| Report Duplicate | Flag | PURGE

Samsung Applications Developer - 0of 0 votes

AnswerA delivery boy wants to deliver some items on his way from office to home. You need to find the optimized path he should take from office to home and deliver all his deliveries on his way.

- mirinda January 09, 2016 in India

It is 101 X 101 grid. Office, home , delivery points are represented via coordinated (x,y) where 0 <= x <= 100, 0 <= y <= 100.

distance between two points (x1, y1) and (x2,y2) is computed as |x1 - x2| + |y1 - y2|

You need to find the optimized path from office to home covering all delivery locations and return the optimized path length as output.

You will be given the input in the 2 lines

first line - N (no. of delivery locations)

second line - (x,y) coordinates of office, followed by home, followed by all N delivery locations.

3

0 0 100 100 20 30 50 50 70 70

output: The length of the optimized path taken.

For above input, the output is 200| Report Duplicate | Flag | PURGE

Samsung Software Developer Problem Solving - 1of 1 vote

AnswersWAP to get following.

- Razz September 04, 2015 in United States

input : {2, 4, 3, 5, 6}

output: {360, 180, 240, 144, 120 }

Hint: {4*3*5*6, 2*3*5*6, 2*4*5*6, 2*4*3*5}

Please note, division is not allowed and time complexity should be O(N).| Report Duplicate | Flag | PURGE

Samsung SDE-2 - 0of 0 votes

AnswersThere are N pots. Every pots has some water in it. They may be partially filled . Every pot is associated with overflow number O which tell how many minimum no. of stones required for that pot to overflow. The crow know O1 to On(overflow no. for all the pots). Crow wants some K pots to be overflow. So the task is minimum number of stones he can make K pots overflow in worst case.

- sas.rockks May 05, 2015 in India

Array of overflow no--. {1,...On}

Number of pots--n

No of pots to overflow-- k

Let say two pots are there with overflow no.s {5,58}, and crow has to overflow one pot(k=1). So crow will put 5 stones in pot with overflow no.(58), it will not overflow, then he will put in pot with overflow no.(5), hence the total no. of stones to make overflow one pot is=10.

What are the best algorithm to do it?| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 0of 0 votes

Answers

- nebeew November 24, 2014 in India`You are given an mxn grid, where (0,0) refers top most left position and (m-1,n-1) the bottom most right. The grid is filled with ones. All positions in the grid that are blocked are filled with zeros. You are given this grid and are assured that there exists atleast one path from (0,0) to (m-1, n-1). Find the minimum distance of the path from (0,0) to (m-1, n-1) given that you are allowed to move only vertically, horizontally and diagonally`

| Report Duplicate | Flag | PURGE

Samsung Developer Program Engineer - 0of 0 votes

AnswersCheck if tree is BST.

- newbee September 24, 2014 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 1of 1 vote

AnswersWe have a char array and we need to reverse it. say Char Array is “Northern California USA”, need to print “USA California Northern”. Can’t use any other data structures or buffer. Can only use a char temp.

- newbee September 24, 2014 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 0of 0 votes

AnswersFind the kth minimum element into binary search.

- newbee September 24, 2014 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 0of 0 votes

AnswersWe have array of strings. Go through each element of array and eliminate duplicates if any string is having. You have to save in the same array.

- newbee September 24, 2014 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 0of 0 votes

AnswersWhat is memory alignment in terms of compiler

- arpitsardhana2008 September 14, 2014 in India for networking| Report Duplicate | Flag | PURGE

Samsung Software Engineer / Developer - 0of 0 votes

Answerwhat are types of memory issues one faces

- arpitsardhana2008 September 14, 2014 in India for networking| Report Duplicate | Flag | PURGE

Samsung Software Engineer / Developer Debugging - 0of 0 votes

AnswersWrite a program to find 2 complement of number

- arpitsardhana2008 September 14, 2014 in India for networking| Report Duplicate | Flag | PURGE

Samsung Software Engineer / Developer C#

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window