Solved LeetCode program · 847 of 1,000
#1131 · Maximum of Absolute Value Expression
Original English source
The firsts is a list of 1, 2, 3, and 4. The seconds is a list of -1, 4, 5, and 6. The best is 0.
For every left from 0 to 3.
For every right from 0 to 3.
The firstgap is the absolute value of (item left of firsts minus item right of firsts). The secondgap is the absolute value of (item left of seconds minus item right of seconds). The indexgap is the absolute value of (left minus right). The score is firstgap plus secondgap plus indexgap. If score is more than best, set best to score.
Show best.
Expected stdout
13