Coding Challenge: HackerRank Queen's Attack II: Medium