n soldiers standing in a line. Each soldier is assigned a unique
You have to form a team of 3 soldiers amongst them under the following rules:
- Choose 3 soldiers with index (
k) with rating (
- A team is valid if: (
rating[i] < rating[j] < rating[k]) or (
rating[i] > rating[j] > rating[k]) where (
0 <= i < j < k < n).