SAMSUNG Questions

Career Cup:

GeeksForGeeks

3QF is mainly for SSIR (not sure) where they ask three questions, that are needed to be solved in 70 minutes. So, they are not that important.

GitHub :

1. Biochemical laughing bomb:

Description:

You are busy to promote a newly released film in a movie theatre . the title is 'Biochemical Laughing Bomb' which is about terror. Guerillas drop a biochemical laughing bomb in the middle of a city. once exposed, you have to laugh all your life. The bomb will contaminate four people around it during t second, and another four around each of them during another one second. However, you won't be contaminated if you are not in the adjacent four directions. as the below shows the location of the bomb and affected people , and shows contamination process in seconds and you can figure out that the whole city is contaminated in 8 seconds. In order to protect the city from the epidemic, create a program that figures out when the city will be contaminated by the bomb for the last.

Input

Several test cases can be included in the inputs. T, the number of cases is given in the first row of the inputs. After that, the test cases as many as T (T ≤ 30) are given in a row. The row and column of the city, N and M are given by being separated with a blank on the first row of each test case. (1 ≤ N, M ≤ 100) The status within city is given by being separated with a blank from the second row to N number rows. 1 means people exist and 0 means people do not exist. The coordinate of the row and column on which the bomb fall is given by being separated with a blank on the last row.

Output

For each test case, you should print "Case #T" in the first line where T means the case number. For each test case, you should output how long does it take to contaminate al people on the first row of each test case.

2. Capture the piece

There is a mobile piece and a stationary piece on the N×M chessboard. The available moves of the mobile piece are the same as set out in the image below. You need to capture the stationary piece by moving the mobile piece with the minimum amount of moves.

Write a program to find out the minimum number moves to catch a piece.

Time limit:1 second (java: 2 seconds)

Input

Several test cases can be included in the inputs. T, the number of cases is given in the first row of the inputs. After that, the test cases as many as T (T ≤ 20) are given in a row. N, the numbers of the rows and M, the number of columns of the chessboard are given in the first row of each test case. R & C is the location information of the attacking piece and S & K is the location of the defending pieces and are given in the row at the second line. However, the location of the uppermost end of the left end is (1, 1)

Output

For each test case, you should print "Case #T" in the first line where T means the case number. For each test case, you should output the minimum number of movements to catch a defending piece at the first line of each test case. If not moveable, output equals ‘-1’.

3. Hamiltonian Circuit

Mr. Lee has to travel various offices abroad to assist branches of each place. But he has a problem. The airfare would be real high as all offices he has to visit are in foreign countries. He wants to visit every location only one time and return home with the lowest expense. Help this company-caring man calculate the lowest expense.

Time limit : 1 second (java : 2 seconds)

Input format

Several test cases can be included in the inputs. T, the number of cases is given in the first row of the inputs. After that, the test cases as many as T (T ≤ 30) are given in a row. N, the number of offices to visit is given on the first row per each test case. At this moment, No. 1 office is regarded as his company (Departure point). (1 ≤ N ≤ 12) Airfares are given to move cities in which branches are located from the second row to N number rows. I.e. jth number of ith row is the airfare to move from ith city to jth city. If it is impossible to move between two cities, it is given as zero.

Output format

Output the minimum airfare used to depart from his company, visit all offices, and then return his company on the first row per each test case.

Example of Input

    2
    5
    0 14 4 10 20
    14 0 7 8 7
    4 5 0 7 16
    11 7 9 0 2
    18 7 17 4 0
    5
    9 9 2 9 5
    6 3 5 1 5
    1 8 3 3 3
    6 0 9 6 8
    6 6 9 4 8

Example of Output

    30
    18

4. Jewels in a maze

Description There is a maze that has one entrance and one exit. Jewels are placed in passages of the maze. You want to pick up the jewels after getting into the maze through the entrance and before getting out of it through the exit. You want to get as many jewels as possible, but you don’t want to take the same passage you used once.

When locations of a maze and jewels are given, find out the greatest number of jewels you can get without taking the same passage twice, and the path taken in this case.

Input

There can be more than one test case in the input file. The first line has T, the number of test cases. Then the totally T test cases are provided in the following lines (T ≤ 10 ).

In each test case, In the first line, the size of the maze N (1 ≤ N ≤ 10) is given. The maze is N×N square-shaped. From the second line through N lines, information of the maze is given. “0” means a passage, “1” means a wall, and “2” means a location of a jewel. The entrance is located on the upper-most left passage and the exit is located on the lower-most right passage. There is no case where the path from the entrance to the exit doesn’t exist.

Output

From the first line through N lines, mark the path with 3 and output it. In N+1 line, output the greatest number of jewels that can be picked up. Each test case must be output separately as a empty.

5. Count letters

There is a n x n matrix with only 0s & 1s. Letters are formed using 1 and 0. For eg.-

        U is 1 0 1,  V is 1 0 1
             1 0 1        1 0 1
             1 1 1        0 1 0

Likewise there are 6 letters and they can rotated in 90, 180, 270, 360 degree. And if there is a letter, the next column would be filled with 0. Eg.

         V- 1 0 1 0
            1 0 1 0
            0 1 0 0

So we have to count the number of each letter in the matrix.

6. Convex hulls

You are given 2 convex hulls. Find all the common points that lie in the intersection of these 2 convex hulls.

7. Maximum sum in a matrix

Given an NxM (N rows and M columns) integer matrix with non-negative values (0..MAX_INT inclusive). What is the maximum sum from going top left (0, 0) to bottom right (N-1, M-1) ? The condition is that when you're at point (p, q), you can only move to either right (p, q+1) or down (p+1, q).

8. Number of unique binary search trees

You are given N unique numbers a1<a2<a3<...an. Find out the count of all possible binary search tress that can be constructed using these numbers. For example with 3 elements 1,2,3 there are 5 possible BST and for 1,2,3,4 there are 14 BST.</p>

9. Convex polygon with minimum area:

Given random points in a 2-D plane, construct a convex polygon with minimum area of covering and which encompasses all the given points.

10. Distance of the closest leaf in a binary tree

Given a Binary Tree and a node x in it, find distance of the closest leaf to x in Binary Tree. If given node itself is a leaf, then distance is 0.

11. Size of the largest subtree

Given a Binary Tree, write a function that returns the size of the largest subtree which is also a Binary Search Tree (BST). If the complete Binary Tree is BST, then return the size of whole tree.

12. Date to day

Write a function that calculates the day of the week for any particular date in the past or future. A typical application is to calculate the day of the week on which someone was born or some other special event occurred.

13. Men's restroom problem

Men's restroom problem : It is a well-researched fact that men in a restroom generally prefer to maximize their distance from already occupied stalls, by occupying the middle of the longest sequence of unoccupied places. For detailed version, check the following link.

Important questions:

  • Bipartite. Done.
  • Worm holes. Done.
  • Rare elements. Don't understand the question properly.
  • Kim and refridgerators. Done.
  • Physical Energy. Don't understand the question properly.
  • Balloon Bursting. Done.
  • Number deletions. Done.
  • Cycle or not. Done.
  • Spaceship. Done.
  • Endoscopy

Thapar:

  1. 1 1
  2. 1

Want to expand this list? I don't.

Report abuse