Solved LeetCode program · 324 of 1,000
#0442 · Find All Duplicates in an Array
Original English source
Keep a shared nums holding 4, 3, 2, 7, 8, 2, 3, and 1. Keep a shared tally of 0. Keep a shared earlierfound of 0. Keep a shared origin of 0.
To tally from spot (a whole number) with value (a whole number). If spot is more than 7, return. If item spot of nums is value, add 1 to tally. Tally from spot plus 1 with value.
To earlier from spot (a whole number) with value (a whole number). If spot is at least origin, return. If item spot of nums is value, set earlierfound to 1, return. Earlier from spot plus 1 with value.
The answers is an empty list of whole numbers.
For every spot from 0 to 7.
The value is item spot of nums. Set tally to 0. Set origin to spot. Tally from 0 with value. If tally is more than 1, set earlierfound to 0. If tally is more than 1, earlier from 0 with value. If tally is more than 1 and earlierfound is 0, Place value into answers.
Sort answers. The line is empty text.
For each answer in answers.
If the length of line is more than 0, Place "," into line. Place format whole number answer as text into line.
Show line.
Expected stdout
2,3