https://ide.codingblocks.com/#/s/24409
https://hack.codingblocks.com/contests/c/457/215
Arrays-Target Sum Triplets
-
Your solution is O(N^3) which will give TLE as N is 1000. So think of sorting the array and using two pointer technique to solve this one.
-
I think you have to print triplets in lexographically sorted order, so if you sort the array before running your code, it wont prodce wrong answer