Interview Question


Country: United States




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

Suppose you are given a mxn rectangle, where m>=n

Then the total number of squares = m*n + (m-1)*(n-1) + (m-2)*(n-2).+..+(m-n-1)*(n-n-1)
In closed form, it becomes,
sum of the terms: (m-j)*(n-j) where j = 0..n-1

- Murali Mohan January 17, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Minor correction: the last term should be "(m-(n-1))*(n-(n-1))"
(the closed form is OK)

- Joker.eph January 19, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Very nice... But needs serious understanding why this works.

- DS January 20, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Joker.eph.
Thanks for the correction.

- Murali Mohan January 20, 2014 | Flag


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