Knight Moves Queries
There is a knight on an infinite chessboard. The rows and columns are 1-indexed. Your task is to efficiently process queries of the form: when the knight starts at position (x,y), what is the minimum number of moves the knight needs to do to reach the top-left corner. Input The first line has an integer n: the number of queries. After this, there are n lines. Each line has two integers x and y
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start