- All the following tasks can be done without adding any other dependencies
- Do not modify the unit tests. They will all pass once the code is fixed
The project contains a service - NumberService. The service has a public method findSmallestDuplicate, which accepts a list of numbers and returns the smallest duplicate or null if there are no duplicates.
Implement the findSmallestDuplicateImproved method so that the unit tests pass. The unit tests assert that:
- The number that the new method (findSmallestDuplicateImproved) finds is the same as the slow running method (findSmallestDuplicate)
- The new method is at least 1000 times faster than the old one.
- Null value is returned if there are no duplicates.