

Given ‘N’ = 4, ‘numMisha’ = 2.
The options available to us are 1, 3, and 4. In this case, choosing 3 would be most optimal because the probability that Andrew wins is 2 / 4, whereas if he chooses 1 or 4 it would be 1 / 4.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘T’ lines contain 2 space-separated integers ‘N’, the range given to us, and ‘numMisha’ the number Ninja Misha chose.
For each test case, You are supposed to return the number Andrew should choose such that he has a higher probability of winning.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= ‘T’ <= 10
1 <= ‘N’ <= 10 ^ 6
1 <= ‘numMisha’ <= ‘N’
Time Limit: 1sec.
The idea is to observe that if we choose the median of the first ‘N’ numbers, then we will be close to at least ‘N / 2’ numbers, to that extent, if Misha chose number less than the median than choosing number just next to it would be most optimal since it will give us all the extra numbers between her number and median. Similarly, if she chose a number greater than the median, then choosing a number just less than her would be most optimal.
The steps are as follows:
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers