Count Number of Teams
You are given an integer array rating of size n, where rating[i] is the rating of the ith soldier.
A team consists of any three soldiers rating[i], rating[j], and rating[k] with i < j < k. A team is valid if:
rating[i] < rating[j] < rating[k] for teams of three, or rating[i] > rating[j] > rating[k] for teams of three.
Return the number of valid teams you can form.
Ada AI
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?
javascript (node 13.12.0)