We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi,
I cant understand something:
This is worked for me only when I'm trying to provide a sorted array,
like this: [ 1,1, 5, 5, 25, 125] - res is 6,
but when the array is not sorted like this [ 1, 5, 5, 25, 125, 1]
the result is difference - 4.
It passed a test with unsorted array, so what am I missing here? Why is the order matter?
Thanks!
Update:
Just noticed that the order of the triplet is matter, and that the order of the triplet (i,j,k) must implement i < j , k.
Count Triplets
You are viewing a single comment's thread. Return to all comments →
Hi, I cant understand something: This is worked for me only when I'm trying to provide a sorted array, like this: [ 1,1, 5, 5, 25, 125] - res is 6, but when the array is not sorted like this [ 1, 5, 5, 25, 125, 1] the result is difference - 4. It passed a test with unsorted array, so what am I missing here? Why is the order matter? Thanks!
Update: Just noticed that the order of the triplet is matter, and that the order of the triplet (i,j,k) must implement i < j , k.