New position

You are given two integers n and k. Assume numbers from 1 to n are arranged in a way that - all odd numbers (in ascending order) comes first and then comes to all even numbers (also in ascending order).

You need to find and return the integer which is at position k (numbering of positions start from 1).

Input Format :
Line 1 : Integer n
Line 2 : Integer k
Output Format :
Integer at position k

Constraints :

1 <= k <= n <= 10^12
Sample Input:
7
4
Sample Output:
7
Sample Output Explanation :

Numbers from 1 to 7 are arranged as - (1, 3, 5, 7, 2, 4, 6) and number at position 4 is 7. So, the output is 7.

Comments

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius