Queen's Attack II Discussions | Algorithms | HackerRank
We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
obs_map = {}
for obs in obstacles:
obs_map[obs[0], obs[1]] = 1
deltas = [0, 1, -1]
directions = []
for i in deltas:
for j in deltas:
if i != 0 or j != 0:
directions.append((i, j))
count = 0
for direction in directions:
i, j = r_q + direction[0], c_q + direction[1]
while obs_map.get((i, j)) is None and i > 0 and j > 0 and i < n+1 and j < n+1:
count += 1
i += direction[0]
j += direction[1]
return count
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Queen's Attack II
You are viewing a single comment's thread. Return to all comments →
def queensAttack(n, k, r_q, c_q, obstacles):