All practice tasks

Coding (Algo)

Split a Batch Into Equal Totals

Dynamic programming · Medium

A batch contains indivisible non-negative workload amounts. A planner wants to know whether the entries can be assigned to two groups with the same total. Every entry must belong to one group, and identical amounts at different indexes remain separate entries.

Return whether all entries can be partitioned into two subsets with exactly equal sums.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ nums: integer[] }

Fields

  • nums contains non-negative integers. Every occurrence is usable exactly once.

Output

Return value

  • Return a boolean, not the groups themselves. Either group may be empty.
  • An empty batch returns true. An odd total cannot be split equally.

Constraints

  • 0 <= nums.length <= 200; 0 <= nums[i] <= 20000; sum(nums) <= 20000.

Examples

Example 1

{
  "nums": [
    1,
    5,
    11,
    5
  ]
}

Returns

true

Example 2

{
  "nums": [
    1,
    2,
    5
  ]
}

Returns

false

Required complexity

O(n × S) time and O(S) auxiliary space where S is half the total

What this task practices

Split a Batch Into Equal Totals is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.