Please help me understand this problem? (GVAWAY)

it’s simple .
if L and R are equal then output is 1
else the output will be K


sir, let’s say that l is 1 and r is 3.
Now this means that total distinct number between 1 and 3 is 1,2,3 i.e three numbers are distinct between 1 and 3.
then total distinct no that we can choose is 3 only(i.e 1,2,3)
then how the answer will be 4 ?

In the question it is clearly mentioned that you have to choose K “real” numbers , not the K “integers” . And there r infinite many real numbers between any two integers numbers .


thanks for helping !

so why the answer is 4 buddy please explain

1 Like

Answer is 4 as you have to choose K real numbers in the interval [ l , r ] , and there are infinite many possible real numbers exists in the interval [ l , r ] . Here , we are required to output the count of distinct numbers that we can choose in the interval [ l , r ] .


When L is equal to R and K>1, should not the output be zero, as there is no possible way to choose k distinct numbers?