Solved LeetCode program · 906 of 1,000
#1253 · Reconstruct a 2-Row Binary Matrix
Original English source
The upper is 2, while the lower is 1. The sums is a list of 1, 1, and 1. The tops is an empty list of whole numbers. The bottoms is an empty list of whole numbers.
For each amount in sums.
If amount is 2, Place 1 into tops, Place 1 into bottoms.
If amount is 1.
If upper is more than 0, Place 1 into tops, Place 0 into bottoms, subtract 1 from upper, otherwise Place 0 into tops, Place 1 into bottoms, subtract 1 from lower.
The topline is empty text. The bottomline is empty text.
For every spot from 0 to the last position of tops.
If spot is more than 0, Place "," into topline. Place format whole number item spot of tops as text into topline. If spot is more than 0, Place "," into bottomline. Place format whole number item spot of bottoms as text into bottomline.
Show topline. Show bottomline.
Expected stdout
1,1,0 0,0,1