The TransCompilator

Solved LeetCode program · 224 of 1,000

#0287 · Find the Duplicate Number

Medium Array chunk-05.md

Original English source

Keep a shared numbers holding 1, 3, 4, 2, and 2. Keep a shared seek of 0. Keep a shared tally of 0.

To gather from spot (a whole number) with last (a whole number). If spot is more than last, return. If item spot of numbers is seek, add 1 to tally. Gather from spot plus 1 with last.

The duplicate is 0.
For every spot from 0 to 4.
Set seek to item spot of numbers. Set tally to 0. Gather from 0 with spot minus 1. If tally is more than 0, set duplicate to seek.

Show duplicate.

Open in Playground Browse all 1,000 problems

Expected stdout

2