Goldman Sachs Internship Interview Question

Can someone provide a sloution?

Alice and Bob are given an NxN grid, which represents a cake. Both of them wants cream which is represented by a positive number and dislike chocolate toppings which is represented by a negative number. Bob also has a restriction that you can cut two pieces such that both the pieces can be either a square or a rectangle. But both the pieces should have a common corner. It can't have more than one common corner. Also the amount of cream on both the pieces should be same.

Find the number of ways for such a cut.

Example:


[1,2,3]

[2,3,4]

[4,5,8]

Then


[1,2,.]

[2,3,.]

[.,.,.]

and

[.,.,.]

[.,.,.]

[.,.,8]

``` can be two such pieces.

Constraints: 2<=N<=100
Comments (4)