# Samsung Interview Questions asked in Samsung 3 Hour Test | Set 4

1. There 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 a fair manner. Remember the companies can have oil mines adjacent to each other and not in between of each other. After distributing them compute the difference 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).

Example
Input

2 4
6 13 10 2
2 4
6 10 13 2

Output

1

2. A 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.

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.

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