Data Structures19 sections · 729 units
Open in CourseQuiz: 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?
- A.To avoid using the same element twice (e.g., target=6, element=3)
- B.To handle duplicate values correctly
- C.The order doesn't matter, either way works
- D.To make the code run faster