Productive Worker Teams
Learn this problemProblem statement
The manager of an Amazon warehouse wants to create a productive team of four workers for their latest order.
There are n workers, where the level of the jth worker is represented by the array level[j], and the level of each worker is a unique integer from 1 to n. The higher the level of a worker, the more skillful and experienced the worker is.
A team of four workers [x, y, z, w], where 1 <= x < y < z < w <= n, is called productive if it satisfies the following conditions:
level[x] < level[z]level[y] > level[w]- The order of workers in the team must follow their order in the
levelarray, i.e. the team must be formed by choosing four distinct workers with increasing indices.
The manager wants to know the number of choices for creating a productive team. Given n workers and an array level, find the number of choices for creating a productive team.
Note:
- The array
levelis a permutation. A permutation is one in which each element from1tonappears exactly once. - Two tuples
[x1, y1, z1, w1]and[x2, y2, z2, w2]are considered to be different ifx1 != x2ory1 != y2orz1 != z2orw1 != w2.
Function
countProductiveTeams(n: int, level: int[]) → longExamples
Example 1
n = 5level = [11, 14, 12, 13, 15]return = 1The productive team is formed by worker positions [1, 2, 3, 4]. It satisfies level[1] < level[3] because 11 < 12, and level[2] > level[4] because 14 > 13.
Source note (June 29, 2026): The original source image did not include the output for this example. FastPrep copied the example input exactly from the source image and worked out the output from the stated tuple conditions. If you have the original output or notice something wrong, please let us know and we'll fix it. If we find a fuller source later, we'll come back and update this too. 🐣
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026