Queen's Attack II Discussions | Algorithms | HackerRank
  • + 55 comments

    Java Solution Here is my solution in Java that passes all cases in O(k) time with O(1) space.

    Here is how it works: We loop through the obstacles given and keep track of the closest one to our queen in each of the 8 directions, then we calculate the distance from our queen to each of the closest obstacles and return their sum.