1. Learn
  2. /
  3. Courses
  4. /
  5. Optimizing Code in Java

Connected

Exercise

Implementing a duplicate transaction finder

Financial transaction logs must be validated to ensure each transaction ID is unique. Your task is to implement a method that efficiently checks for the presence of any duplicate transaction IDs.

Instructions

100 XP
  • Initialize the seen variable as an empty Set.
  • Add transactions to seen if you've not encountered them before.
  • Return the appropriate boolean value if the loop ends without finding a duplicate.