...

/

Solution: Two Sum III - Data structure design

Solution: Two Sum III - Data structure design

Let's solve the Two Sum III - Data structure design problem using the Custom Data Structures pattern.

Statement

Design a data structure that takes in a stream of numbers and can check if any two numbers add up to a specific value.

Implement the TwoSum class with the following constructor and methods:

  • Constructor: Sets up the TwoSum object with an empty list at the start.

  • void add(int number): Adds a new number to the list.

  • boolean find(int value): Returns TRUE if any two numbers in the list add up to the given value. If not, it returns FALSE.

Constraints:

  • 105 ...

Access this course and 1400+ top-rated courses and projects.