The TransCompilator

Solved LeetCode program · 18 of 1,000

#0018 · 4Sum

Medium Array chunk-01.md

Original English source

The nums is a list of 1, 0, -1, and 2. The target is 2. Sort nums. The last is the last position of nums.
For every first from 0 to last.
For every second from one more than first to last.
For every third from one more than second to last.
For every fourth from one more than third to last.
The total is item first of nums plus item second of nums plus item third of nums plus item fourth of nums. If total is target, show item first of nums, show item second of nums, show item third of nums, show item fourth of nums, show "---".

Open in Playground Browse all 1,000 problems

Expected stdout

-1
0
1
2
---