Square Board : Grasshoper on ChessBroad




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

Suppose you place the grasshopper at a particular cell (a,b). Now count the number of cells the grasshopper can reach (called da.b). Note that it can only jump x centimeters at a time.

Do this counting for each cell. Find the cells which have maximum possible da.b value. Output the count.

This can be done via programming brute force.

But yes, seems like there should be an easy mathematical solution.

- Anonymous April 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

input 3 3 2
output 4

xxx
xxx
xxx

GJJ
Jxx = 4
XJX

JGJ
XJX = 4
XJX

all possible combination gives max 4 cells.. and total count is 5
how answer is 4?

- somebody April 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Help Me

- Somebody November 14, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I found one solution but i don't know how to deal with large array sizes

Convert the board into graph such each cell represent each vertex.The cells which are reachable from current cell in one jump are adjacent to current cell.
We need to find the largest connected component in this array.

The solution is the number of vertices in that component.

- Anonymous November 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