The TransCompilator

Solved LeetCode program · 961 of 1,000

#1330 · Reverse Subarray To Maximize Array Value

Hard Array chunk-20.md

Original English source

Keep a shared numbers as an empty list of whole numbers. Keep a shared total of 0. Keep a shared mapped of 0. Keep a shared best of 0. Place 2 into numbers. Place 3 into numbers. Place 1 into numbers. Place 5 into numbers. Place 4 into numbers.

To map from spot (a whole number) with left (a whole number) and right (a whole number). If spot is at least left and spot is at most right, Set mapped to left plus right minus spot, otherwise Set mapped to spot.

To measure from left (a whole number) with right (a whole number). Set total to 0.
For every edge from 0 to 3.
Map from edge with left and right. The first is mapped. Map from edge plus 1 with left and right. The second is mapped. The one is item first of numbers. The two is item second of numbers. The gap is the absolute value of (one minus two). Add gap to total.

To compare. If total is more than best, Set best to total.

For every left from 0 to 4.
For every right from left to 4.
Measure from left with right. Compare.

Show best.

Open in Playground Browse all 1,000 problems

Expected stdout

10