#38Sequential vs parallel wall-clockEasy

Sequential vs parallel wall-clock

Background

The executors do the same total work either way; what changes is wall-clock time:

  • sequential: each executor waits for the previous one → total = sum of depths.
  • parallel: all launch together → total = max depth (the slowest one).

Five executors of depth 2: sequential 10, parallel 2.

Problem statement

Implement wall_clock(depths, mode) returning the wall-clock time.

Input

  • depths — list of per-executor step counts.
  • mode"sequential" or "parallel".

Output

Returns an int: sum(depths) for "sequential", max(depths) for "parallel" (0 if empty).

Examples

Example 1

Input:  depths = [2, 2, 2, 2, 2], mode = "sequential"
Output: 10

Example 2

Input:  depths = [2, 2, 2, 2, 2], mode = "parallel"
Output: 2

Constraints

  • "sequential"sum; "parallel"max.
  • Empty list → 0 for both.

Notes

  • Total compute is unchanged — only the latency collapses. That's why parallelism is "free" when the tasks are independent.
Python
Loading...

▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.

  • Reference example: sequential is the sum
  • Sample: parallel is the max
  • Reference: uneven depths in both modes