A team has tasks with story points in points. The manager wants to split all tasks into exactly k sprints so that every sprint has the same total of points.
Write canSplitEvenly(points, k) that returns true if every task can be put in exactly one sprint so that all k sprint totals are equal, and false otherwise. Every point value is at least 1, so each sprint will hold at least one task.
Input: points = [5,1,4,2,3,3], k = 3 Output: true
The total is 18, so each sprint needs 6: 5 + 1, 4 + 2, and 3 + 3.
Input: points = [3,3,3,4], k = 2 Output: false
The total is 13, which can't be split into 2 equal whole totals.
1 <= k <= points.length <= 161 <= points[i] <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #309 Split Tasks Into Equal Sprints. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.