Pythagorean Triplet Alternate Method

I dont know why my my test cases are coming out to be wrong. I have used an alternative approach. It took me 4 hours to think it out it would be helpful if someone could have a look https://ide.codingblocks.com/s/138936

Hello @d_codr,

Your approach is correct.
But, it is not satisfying the constraints of the question:

  1. N can be any number upto 10^9.
    So, the value of b and c will be larger than int.
    Solution:
    Make a, b and c of type long long.

  2. After satisfying above, it will cause TLE for larger value of n.
    Solution:
    Reduce number of iterations.
    For this, follow the approach explained in the video: Pythagorean Triplet Hint

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.