Solved LeetCode program · 932 of 1,000
#1296 · Divide Array in Sets of K Consecutive Numbers
Original English source
Keep a shared counts as an empty list of whole numbers. Keep a shared highest of 0. Keep a shared span of 4. Keep a shared possible of 1. The numbers is a list of 1, 2, 3, 3, 4, 4, 5, and 6. The last is the last position of numbers. Set highest to item 0 of numbers.
For every spot from 1 to last.
If item spot of numbers is more than highest, set highest to item spot of numbers.
For every spot from 0 to highest, Place 0 into counts.
For every spot from 0 to last.
Increase item (item spot of numbers) of counts by 1.
To build from base (a whole number).
For every offset from 0 to span minus 1.
If possible is 0, return. The wanted is base plus offset. If wanted is more than highest, set possible to 0, return. If item wanted of counts is 0, set possible to 0, return. Decrease item wanted of counts by 1.
For every value from 0 to highest.
Repeat while item value of counts is more than 0 and possible is 1.
Build from value.
If possible is 1, show true, otherwise show false.
Expected stdout
true