Solved LeetCode program · 444 of 1,000
#0624 · Maximum Distance in Arrays
Original English source
Keep a shared numbers holding 1, 2, 3, 4, 5, 1, 2, and 3. The starts is a list of 0, 3, and 5. The sizes is a list of 3, 2, and 3. Keep a shared smallest of 0. Keep a shared largest of 0.
To scan from spot (a whole number) with finish (a whole number). If spot is more than finish, return. The amount is item spot of numbers. If amount is less than smallest, set smallest to amount. If amount is more than largest, set largest to amount. Scan from spot plus 1 with finish.
Set smallest to item 0 of numbers. Set largest to item 0 of numbers. Scan from 0 with 2. The low is smallest. The high is largest. The best is 0.
For every band from 1 to 2.
The start is item band of starts. The finish is start plus item band of sizes minus 1. Set smallest to item start of numbers. Set largest to item start of numbers. Scan from start with finish. The down is largest minus low. The up is high minus smallest. If down is more than best, set best to down. If up is more than best, set best to up. If smallest is less than low, set low to smallest. If largest is more than high, set high to largest.
Show best.
Expected stdout
4