The TransCompilator

Solved LeetCode program · 244 of 1,000

#0327 · Count of Range Sum

Hard Array chunk-05.md

Original English source

Keep a shared sums as an empty list of whole numbers. Keep a shared lower of 0. Keep a shared upper of 0. Keep a shared count of 0. The numbers is a list of -2, 5, and -1. Set lower to -2. Set upper to 2.
For every spot from 0 to 3.
Place 0 into sums.

For every spot from 1 to 3.
Set item spot of sums to item (spot minus 1) of sums plus item (spot minus 1) of numbers.

To scan from right (a whole number) with left (a whole number). If left is at least right, return. The difference is item right of sums minus item left of sums. If difference is at least lower and difference is at most upper, add 1 to count. Scan from right with left plus 1.

For every right from 1 to 3.
Scan from right with 0.

Show count.

Open in Playground Browse all 1,000 problems

Expected stdout

3