The TransCompilator

Solved LeetCode program · 499 of 1,000

#0698 · Partition to K Equal Sum Subsets

Medium Array chunk-10.md

Original English source

Keep a shared numbers as an empty list of whole numbers. Keep a shared groups as an empty list of whole numbers. Keep a shared count of 0. Keep a shared bins of 0. Keep a shared target of 0. Keep a shared found of 0. Place 4 into numbers. Place 3 into numbers. Place 2 into numbers. Place 3 into numbers. Place 5 into numbers. Place 2 into numbers. Place 1 into numbers. Set count to 7. Set bins to 4. The total is 0.
For each value in numbers.
Increase total by value.

Set target to total divided by bins. Sort numbers.
For every group from 0 to bins minus 1.
Place 0 into groups.

To trygroup from spot (a whole number) with group (a whole number). If found is 1, return. The here is count minus 1 minus spot. The value is item here of numbers. If item group of groups plus value is more than target, return. Increase item group of groups by value. Fill from spot plus 1. Decrease item group of groups by value.

To fill from spot (a whole number). If found is 1, return. If spot is at least count, set found to 1, return.
For every group from 0 to bins minus 1.
Trygroup from spot with group.

Fill from 0. If found is 1, show true, otherwise show false.

Open in Playground Browse all 1,000 problems

Expected stdout

true