Data Structures19 sections · 729 units
Open in Course

Quiz: Two Sum Pattern

Order of operations

Check Your Understanding

In two-sum, why do we check for the complement BEFORE adding the current element to the map?

  1. A.To avoid using the same element twice (e.g., target=6, element=3)
  2. B.To handle duplicate values correctly
  3. C.The order doesn't matter, either way works
  4. D.To make the code run faster
Start the roadmap to answer the quizzes and solve the challenges