FastPrepReduce-Based Map and Filter Pipeline
Problems/Reduce-Based Map and Filter Pipeline

Reduce-Based Map and Filter Pipeline

Tesla logoTesla● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report explicitly asks the candidate to implement reduce, map, and filter, with map and filter built from reduce, then process a table through them. The array-stage adapter exposes all three results and matches that task at about 92%.

Run three functional stages on values:

  1. Map each value to value * multiplier.
  2. Filter the mapped sequence to values greater than or equal to minimum.
  3. Reduce the filtered sequence by summing it from an initial value of zero.

Return three rows: the mapped sequence, the filtered sequence, and a one-element row containing the sum. Preserve order. Implementing reusable reduce-based helpers is encouraged.

Function

functionalStages(values: int[], multiplier: int, minimum: int) → int[][]

Examples

Example 1

values = [1,2,3]multiplier = 2minimum = 4return = [[2,4,6],[4,6],[10]]

Mapping doubles the values; 4 and 6 survive and sum to 10.

Example 2

values = [-2,0,3]multiplier = -1minimum = 0return = [[2,0,-3],[2,0],[2]]

Order remains unchanged after mapping and filtering.

Example 3

values = [1,2]multiplier = 3minimum = 10return = [[3,6],[],[0]]

An empty filtered sequence reduces to the zero initial value.

Constraints

  • 0 <= values.length <= 10^5.
  • All products and the final sum fit signed 32-bit range.

More Tesla problems

  • Flatten a Branched List into a Doubly Linked ListPHONE SCREEN · Seen Sep 2026
  • Resilient Fake API ClientPHONE SCREEN · Seen Sep 2026
  • Alternate Positive and Negative ValuesONSITE INTERVIEW · Seen Aug 2026
All Tesla interview questionsSee Tesla hiring insights
Saved
class Solution {
    public int[][] functionalStages(int[] values, int multiplier, int minimum) {
        // Write your solution here.
    }
}
Checking account…