Solved LeetCode program · 190 of 1,000
#0219 · Contains Duplicate II
Original English source
The numbers is a list of 1, 2, 3, and 1. The distance is 3. The last is the last position of numbers. The found is 0.
For every left from 0 to last.
For every right from left plus 1 to last.
The gap is right minus left. If gap is at most distance and item left of numbers is item right of numbers, set found to 1.
If found is 1, show true, otherwise show false.
Expected stdout
true