Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Teams

med
30 min
Try to solve the Count Number of Teams problem.

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

med
30 min
Try to solve the Count Number of Teams problem.

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.