Google | SDE Intern |2021
Anonymous User
2575

Hello Everyone,
I had given test of google for SDE intern ,although I am not able to solve this
Here is the question:

1.You are given an N*N matrix A. The matrix contains positive integers-
In one move you can apply single transformation to the matrix:
Select an arbitrary element of the matrix and increase or decrease it by 1 .Each element can be increased or decreased for any arbitrary number of times.

A special number P is a non-negative integer for which of the following quadratic equation has at least one non-negative integer root:

x^2-2*P+x = 0

A matrix is called special if atleast one of the following comdition is true-
a)The matrix has a row with special numbers only.
b)The matrix has a column with special numbers only.
your task is to count minimum number of moves required to get a special matrix from A.

input- first line test cases
second line N
next N lines of each tc contains n integers denoting the initial matrix A.

Constraints- 1<=T <=10,1<=N<=500,1<=A[i][j]<=10^11

Sample input-
1
3
1 2 3
4 5 6
7 8 9
Sample output- 1

anyone can help with this question ??

Comments (4)