Skip to the code
cf.
+25 XP

#559 Split Tasks Into K Equal Lanes

medium

A kanban board has k swimlanes, and a manager wants to spread tasks with effort points efforts across them so that every lane has exactly the same total effort. Every task goes into exactly one lane.

Write canSplitIntoLanes(efforts, k) that returns true if such a split exists, and false otherwise.

Example 1

Input: efforts = [5,1,4,2,3,3], k = 3
Output: true

Lanes of 5 + 1, 4 + 2, and 3 + 3, each adding up to 6.

Example 2

Input: efforts = [1,2,3,4], k = 3
Output: false

The total is 10, which can't be split into 3 equal whole parts.

Constraints

  • 1 <= k <= efforts.length <= 16
  • 1 <= efforts[i] <= 10000
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).