Kth Root question

Please check my solution and guide me for failing the test cases.
Link to code file:

Hello @nikunj19093,

  1. Your code is giving TLE for the test cases like:
    1
    1000000000000000 1
    Expected Output:
    1000000000000000
    Solution:
    Use binary search with start=1 and end=n to find the required value of x instead of the linear search.

  2. Your code is giving wrong output for the cases:
    7
    1000000000000 100
    Expected Output:
    6
    Reason:
    2^100 is a large value, even lager than the positive range of long.
    As we know when a value exceeds the given range of the dataset, it is cycled over the other end of thus. Thus, it is producing the negative value as ans.
    Hence, your code is iterating untill x=6, for which after cycling over the negative end of the range, the ans lands to a positive value grater than n.

Hope, this would help.
Give a like if you are satisfied.

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.