educative.io

Problematic example

[3, 4, 4, 4, 2]
3 duplicates


Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Find The Duplicate Number

1 Like

Hi @Rami_Mankevich,

Although the term duplicate is used for a thing that occurs 2 times, but in this specific problem, as per the third constraint:

All the integers in nums are unique, except for one integer that will appear more than once.

This means that, a number can be repeated multiple times in an array but keeping in line the constraints of the problem. So, the test case is correct in this regard.

:bulb: Suggestion: You can even write your own test cases by clicking on the “Test Cases” tab in the widget, and start typing in the text box where the test case is provided. By clicking on the “Run” button, you’ll see how your test case executes and behaves in certain scenarios.

I hope this clears up your confusion regarding the duplicates in this problem. Feel free to share further suggestions and feedbacks. We’d be happy to help. Thanks!

Happy learning!