Flipkart Interview Question for Software Engineer / Developers


Country: India
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

Check "Dynamic Programming | Set 27 (Maximum sum rectangle in a 2D matrix)" on geeks for geeks site.

- 42 May 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

convolve the original matrix with the matrix of ones (Kernel) and fing the max value of the 2D matrix. which will return the center position of the submatrix with the largest sum.

Size of the kernal will decide the size of the sunMatrix.
in matlab it can be done like this

orignal2DMatrix;
subMatKernal = ones(sizeOfSubMatrix,sizeOfSubMatrix);
result = conv2(orignal2DMatrix,subMatKernal );
matrixIndex= find(max(result));

- Samit Desai May 19, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Consider that a convolution is of size O(n^2) and therefore contains the sums of only O(n^2) submatrices. However, there are O(n^4) different submatrices, so you're not considering all the possible submatrices.

- eugene.yarovoi May 20, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Logic:

Step 1:
Row wise operation:
Replace the matrix data with the sum of element in row upto current column number.
Replace A[x,y] = A[x,0]+A[x,1]+A[x,2]+A[x,3]+......+A[x,y]
If A =
[1 2 3]
[4 5 6]
[7 8 9]
then after first step:
A=
[1 3 6]
[4 9 15]
[7 15 24]


Step 2:
Column wise operation:
Replace the matrix data with the sum of element in column upto current row number.
Replace A[x,y] = A[0,y]+A[1,y]+A[2,y]+A[3,y]+......+A[x,y]

Now A =
A=
[1 3 6]
[5 12 21]
[12 27 45]


Step 3:
Now find the max diff b/w to A[x,y]-A[x',y'] elements in the result matrix where
X>=X' and
Y>=Y'

- PKT May 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

What will this give answer as can you please explain...

- Anonymous May 22, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Way too easy....

ComputeMax(x1,y1,x2,y2) = max(ComputeMax(x1+1,y1,x2,y2),ComputeMax(x1,y1+1,x2,y2),ComputeMax(x1,y1,x2-1,y2),ComputeMax(x1,y1,x2,y2-1), sum of this whole matrix);

You need to use memoization to reduce re-computations.

- ysoserious June 14, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More