Skip to the code
cf.
+25 XP

#512 Two Sprints of Equal Effort

medium

A team has a list of tickets with effort points in efforts. They want to split all tickets into two sprints so that both sprints have exactly the same total effort. Every ticket goes into exactly one sprint.

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

Example 1

Input: efforts = [2,6,13,5]
Output: true

Sprint A gets 2 + 6 + 5 = 13 and sprint B gets 13.

Example 2

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

The total is 15, which is odd, so it can't be split into two equal halves.

Constraints

  • 1 <= efforts.length <= 200
  • 1 <= efforts[i] <= 100
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).