The TransCompilator

Solved LeetCode program · 318 of 1,000

#0435 · Non-overlapping Intervals

Medium Array chunk-07.md

Original English source

Keep a shared starts holding 1, 2, 3, and 1. Keep a shared ends holding 2, 3, 4, and 3. Keep a shared keystart of 0. Keep a shared keyend of 0.
To shift from spot (a whole number) with marker (a whole number). If marker is less than 0, set item 0 of starts to keystart, set item 0 of ends to keyend, return. If item marker of ends is at most keyend, set item (spot plus 1) of starts to keystart, set item (spot plus 1) of ends to keyend, return. Set item (spot plus 1) of starts to item marker of starts. Set item (spot plus 1) of ends to item marker of ends. Shift from spot minus 1 with marker minus 1.

For every spot from 1 to 3.
Set keystart to item spot of starts. Set keyend to item spot of ends. Shift from spot minus 1 with spot minus 1.

The lastend is item 0 of ends. The removals is 0.
For every spot from 1 to 3.
If item spot of starts is at least lastend, set lastend to item spot of ends, otherwise add 1 to removals.

Show removals.

Open in Playground Browse all 1,000 problems

Expected stdout

1