Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Advanced DP

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Advanced DP

Partition to K Equal Sum Subsets

advancedlayer A1 · Advanced DP5 tests

Given an array of positive integers nums and an integer k, decide whether the array can be split into exactly k non-empty groups that all add up to the same total. Return true or false.

  • Every element must land in exactly one group
  • nums.length is at most 16, so a bitmask over the used elements is the intended shape
  • If the total is not divisible by k the answer is false
  • If any single element is bigger than the per-group target the answer is false

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen