code link: https://ide.codingblocks.com/s/189616
Run time error in 1 test case
this should be time limit exceeded error. your solution is simple one(linear approach) but its time complexity is linear. you can reduce the time complexity to logarithmic by using binary search approach.
assume x values: low = 1 and high = n
and then apply binary search to find right value of x.
Thanks.
please resolve it and rate it if satisfied.
Thanks…
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.