How to convert N^3 time complexity solution to N^2 time complexity solution in C++ ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to convert N^3 time complexity solution to N^2 time complexity solution in C++ ?

I have written an solution with time complexity of order of N^3 but while submitting this solution i get time limit exceeded error for large input. How can we reduce the time complexity to N^2 as the size of input is 1000 and online judge accepts the solution with time complexity of order of N^2 for this size of input? Is their any reference or material to learn on how to reduce the time complexity of any solution? https://code.sololearn.com/c26a226a5A41/?ref=app

15th Jul 2021, 4:33 PM
MahirShah
4 Answers
15th Jul 2021, 6:44 PM
Abhay
Abhay - avatar
+ 1
Find the count of triplets that form a triangle in an array
15th Jul 2021, 5:29 PM
MahirShah
0
What does your code do?
15th Jul 2021, 4:37 PM
Abhay
Abhay - avatar
0
Thanks
16th Jul 2021, 5:00 AM
MahirShah