Move zeros to end21.01
Zeros-to-end is partition with pred non-zero to front. The tail becomes zeros. Decide whether non-zeros keep order.
Count zeros or compact non-zeros then fill. Filling without compacting leaves holes.
Same skill, three traces. Read all three before you try it.
01stable - given
a = [0, 4, 0, 1]- walk
non-zeros
4,1then zeros- result
[4, 1, 0, 0]
02no zeros - given
a = [4, 1]- walk
already done
- result
[4, 1]
03all zeros - given
a = [0, 0]- walk
w=0, fill all- result
[0, 0]
zerosToEnd(a).a is an array of integers.Move zeros to the end. Keep the order of the non-zeros. Return
a.[0, 4, 0, 1] → [4, 1, 0, 0].constraintsa is non-empty.
- Move Zeroes0/3 skills ready · arrays · easyopen
- Move Zeroes0/3 skills ready · arrays · easyopen
Every Check with Awel is frozen here. Open one to read the code or load it back into the editor.