Few of the test cases are not running due to
Time limit Exceeded error.
Can you please help me to approach an optimised solution by providing some hint.
Pythagoras Triplets
Hello Srishti
The approach for this problem should be if the given no. is less than 3 than it is not possible to form a Pythagoras triplet. And if the no. is not divisible by 2 then the other two no. can be get by the formulas (n^2 -1)/2 & (n^2 +1)/2. If the no. is divisible by 2 then we can get the other two no. by the formulas (n^2/4 - 1) & (n^2/4 +1)
Hope Now you will understand and if you still face any issue please let me know.
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.
how to approach that formula …like…whats the thought process behind reaching to that formula.??
Hi Shristi
Your code is absolutely correct just a small error Please take input as long instead of int
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.