EvalFrame Technical Mock Interviews & Coding Practice

Partition Equal Subset Sum

Medium · Dynamic Programming · Algorithm problem · all problems

Given an integer array `nums`, return `true` if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or `false` otherwise. **Examples:** ```typescript canPartition([1, 5, 11, 5]) // true ([1, 5, 5] and [11]) canPartition([1, 2, 3, 5]) // false ```

Solve It in the BrowserPractice Explaining It Out Loud

Optimal Approach

  • Time complexity: O(n * target)
  • Space complexity: O(target)

Standard 0/1 knapsack DP where target is sum(nums) / 2.

Follow-Up Questions Interviewers Ask About Partition Equal Subset Sum

  • Why iterate backwards from target down to num in the inner loop?
    Iterating backwards prevents using the same element multiple times within the same subproblem.

Practice the full problem with execution, tests, and AI code review in the interactive lab — then rehearse explaining your solution in a live voice mock interview.