The TransCompilator

Solved LeetCode program · 90 of 1,000

#0090 · Subsets II

Medium Array chunk-02.md

Original English source

Keep a shared nums holding 1, 2, and 2. Keep a shared parts as an empty list of text. Keep a shared answers as an empty list of text. Keep a shared marker as empty text. Keep a shared built as empty text. Keep a shared piece as empty text. Keep a shared partcount of 0. Place "()" into marker.
To collect from index (a whole number). Set built to join parts with ",". If partcount is 0, set built to marker. Place built into answers.
For every position from index to 2.
If position is more than index and item position of nums is item (position minus 1) of nums, skip to the next one. Set piece to format whole number item position of nums as text. Place piece into parts. Add 1 to partcount. Collect from position plus 1. Remove the last item from parts. Subtract 1 from partcount.

Collect from 0. For each answer in answers, show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

()
1
1,2
1,2,2
2
2,2