## Google Interview Question for Software Engineers

Country: United States

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

I feel like it is like a bfs problem, but I am not sure whether it satisfies interviewer? start from the origin point, and bfs search its surrounding area. Any other idea?

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

``````# Randomly assuming that target is calculated (once reached) as target = target[x]* 7, target[y]* 7
def move(start, target):
queue = collections.deque([[start]])
seen = {start}
while queue:
path = queue.popLeft()
x, y = path[-1]
if x, y == target:
return move((x, y), (target[0] * 7, target[1] * 7))
candidates = {(x + 1, y + 1), (x - 1, y + 1), (x - 1, y - 1), (x + 1, y - 1)}
forbidden_l = get_forbidden_cells()
for can in candidates:
if can not in forbidden_l  and can not in seen:
queue.append(path + [can])

def get_forbidden_cells():
# not relevant, probably O(1)``````

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

ID DFS + BFS

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

to reach any row or col the minimum jumps required is row/col number/2. then need to check which is the target cell. Worst case is 3 extra jumps to reach that cell. we use this formula

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.

### 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.