The TransCompilator

Solved LeetCode program · 968 of 1,000

#1338 · Reduce Array Size to The Half

Medium Array chunk-20.md

Original English source

The items is a list of 3, 3, 3, 3, 5, 5, 5, 2, 2, and 7. The tally is a list of 8 zeros. The counts is an empty list of whole numbers.
For every which from 0 to 9.
The value is item which of items. Increase item value of tally by 1.
For every value from 0 to 7.
If item value of tally is more than 0, Place item value of tally into counts.

For every spot from 1 to the last position of counts.
The hold is item spot of counts. The prior is spot minus 1.
Repeat while prior is at least 0 and item prior of counts is less than hold.
Set item (prior plus 1) of counts to item prior of counts. Subtract 1 from prior. Set item (prior plus 1) of counts to hold.

The target is 5, while the removed is 0, while the answer is 0.
For every spot from 0 to the last position of counts.
Increase removed by item spot of counts. Add 1 to answer. If removed is at least target, stop.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

2