Requirements

  • 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

Improve-performance

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:

  1. The number that the new method (findSmallestDuplicateImproved) finds is the same as the slow running method (findSmallestDuplicate)
  2. The new method is at least 1000 times faster than the old one.
  3. Null value is returned if there are no duplicates.