File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
real_interview_questions/Google Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,11 @@ class Solution(object):
5656 visited_set.add(start_indexes)
5757 distance = result = 0
5858 total_n_buildings_found = 0
59+ memo = dict()
5960
6061 while len(bfs_queue) != 0 and total_n_buildings_found < n_buildings:
6162 n_pops = len(bfs_queue)
6263 distance += 1
63- n_buildings_found = 0
6464 while n_pops > 0:
6565 curr_indexes = bfs_queue.pop()
6666 n_pops -= 1
@@ -72,11 +72,8 @@ class Solution(object):
7272 if element == 0:
7373 bfs_queue.appendleft(neighbor)
7474 elif element == 1:
75- n_buildings_found += 1
75+ result += distance
7676 total_n_buildings_found += 1
77- if n_buildings_found != 0:
78- result += (distance * n_buildings_found)
79- n_buildings_found = 0
8077 if total_n_buildings_found != n_buildings:
8178 return -1
8279 return result
You can’t perform that action at this time.
0 commit comments