Find the -th number in a sequence formed by listing all odd numbers up to first, then all even numbers up to .
You are given two integers and . Consider the sequence of numbers from $1n$ arranged in this order:
Your task is to output the -th number in this sequence.
For example, when , the sequence is:
1 3 5 7 9 2 4 6 8 10
and the 7-th element is 4.
Return the value at position without constructing the entire sequence if possible.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.