Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Teams

Count Number of Teams asks you to count triples of soldiers in an array whose positions follow left to right and whose unique ratings are strictly increasing or strictly decreasing.

Statement

There are n soldiers standing in a line. Each soldier is assigned a unique rating value, represented by an integer array rating.

A team is composed of 33 soldiers located at indices i, j, and k with 0≤i<j<k<n0 \leq i < j < k < n such that one of the following conditions is satisfied:

  • rating[i] << rating[j] << rating[k]

  • rating[i] >> rating[j] >> rating[k]

Return the total number of teams that can be formed according to these rules.

Constraints:

  • n == rating.length

  • 3≤3 \leq n ≤1000\leq 1000

  • 1≤1 \leq rating[i] ≤105\leq 10^5

  • All the integers in rating are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Teams

Count Number of Teams asks you to count triples of soldiers in an array whose positions follow left to right and whose unique ratings are strictly increasing or strictly decreasing.

Statement

There are n soldiers standing in a line. Each soldier is assigned a unique rating value, represented by an integer array rating.

A team is composed of 33 soldiers located at indices i, j, and k with 0≤i<j<k<n0 \leq i < j < k < n such that one of the following conditions is satisfied:

  • rating[i] << rating[j] << rating[k]

  • rating[i] >> rating[j] >> rating[k]

Return the total number of teams that can be formed according to these rules.

Constraints:

  • n == rating.length

  • 3≤3 \leq n ≤1000\leq 1000

  • 1≤1 \leq rating[i] ≤105\leq 10^5

  • All the integers in rating are unique.