The TransCompilator

Solved LeetCode program · 865 of 1,000

#1171 · Remove Zero Sum Consecutive Nodes from Linked List

Medium Linked List chunk-18.md

Original English source

Keep a shared values holding 1, 2, -3, 3, and 1.

Keep a shared nexts holding 1, 2, 3, 4, -1, and 0.

Keep a shared keys as an empty list of whole numbers. Keep a shared places as an empty list of whole numbers. Place 0 into keys. Place 5 into places. Keep a shared running of 0. Keep a shared found of 0.

To seek from target (a whole number) with node (a whole number). Set found to 0. The size is the last position of keys.
For every seen from 0 to size.
If item seen of keys is target, set item (item seen of places) of nexts to item node of nexts, set found to 1, stop. If found is 0, Place target into keys, Place node into places.

For every node from 0 to 4.
The value is item node of values. Increase running by value. Seek from running with node.

The line is empty text. The node is item 5 of nexts.
Repeat while node is at least 0.
The value is item node of values. The word is format whole number value as text. If the length of line is more than 0, Place "," into line. Place word into line. Set node to item node of nexts.

Show line.

Open in Playground Browse all 1,000 problems

Expected stdout

3,1