iRage Screening test Location Mumbai,India Salary Rs.30 lakhs
Anonymous User
2420

please post the solutions if possible!
iRage is a Mumbai based startup ..the following coding problems appeared in screening test for SDE role..time limit 2 hours.
problem 1.
There is an architect, who wants to change the floor of his room (size NxN). She likes grids and wants a similar pattern on the floor. For this task she has asked one of her interns to use the available tiles:

Size of each tile is 1x1.
There are N colours available indexed from 1 to N.
Each colour comes in two variations: matt finish or glossy finish.
There are infinite number of tiles available of each type.
Now intern has randomly chosen the tile for each of the NxN boxes (each of size 1x1).

When the architect inspected the room, she didn't like the pattern and asked the intern to change it as following:

No two tiles in a same row or column can have same spec (Same colour and finishing).

Now, you've to help the intern with the minimum number of tiles that needs to be changed.

Input Format

The first line of the input gives the number of test cases, T. Then T test cases follow. Each test case begins with one line containing an integer N: the side of the square room. Then, N lines follow; each contains N non-zero integers C(i,j). The j-th value on the i-th line represents the colour of the tile in the i-th row and j-th column of the grid. The magnitude of the value gives the color and the sign of the value gives the finishing (- for matt, + for glossy).

Constraints

1 <= T <= 100 -N <= C(i,j) <= N, for all i,j C(i,j) != 0, for all i,j`

Output Format

For each test case, output one line containing y, where y is the minimum number of tiles, that must be changed.

problem 2.
On her birthday, Mary wants to distribute chocolates and candies to her friends.
She has N1 number of chocolates and N2 number of candies.

Mary can give n1 of chocolate and n2 of candies to one friend.
(0 <= n1 <= N1, 0 <=n2 <= N2)
.

She wants to distribute them in such a way that no two of her friends get the same number of chocolates
and same number of candies.

She also wants to distribute to as many friends as she can following
the aforementioned condition.

If Mary has infinite number of friends, what is the largest number
of her friends who will get at least a chocolate or a candy.

Input Format

The first line of the input
gives the number of test cases, T; then T test cases follow.

Each test case consists of one line
with two integers N1 and N2: the numbers of chocolates and the number of candies that
Mary has.

Constraints

1 <= T <= 100 N1 + N2 > 0 0 <= N1 <= 500 0 <= N2 <= 500

Output Format

For each test case, output one line containing y, where y is the largest number of friends
that'll get something as described above.

Comments (4)