Solved LeetCode program · 877 of 1,000
#1200 · Minimum Absolute Difference
Original English source
The numbers is a list of 4, 2, 1, and 3. The last is the last position of numbers.
For every left from 0 to last.
For every right from left to last.
If item right of numbers is less than item left of numbers, swap item left of numbers and item right of numbers.
The best is 1000000.
For every spot from 1 to last.
The gap is item spot of numbers minus item (spot minus 1) of numbers. If gap is less than best, set best to gap.
For every spot from 1 to last.
The gap is item spot of numbers minus item (spot minus 1) of numbers.
If gap is best.
The line is empty text. The first is item (spot minus 1) of numbers. The second is item spot of numbers. The word is format whole number first as text. Place word into line. Place "," into line. The other is format whole number second as text. Place other into line. Show line.
Expected stdout
1,2 2,3 3,4