You are viewing a single comment's thread. Return to all comments →
Typescript -- O(1) solution!
function main() { const t = +readLine(); for (let i = 0; i < t; i++) { const [n, k] = readLine().split(' ').map(x => +x); console.log(k < (n - 1) / 2 ? 1 + 2 * k : 2 * (n - 1 - k)); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse Game
You are viewing a single comment's thread. Return to all comments →
Typescript -- O(1) solution!