1 / 75
Use a hashmap to store complements and return indices when found.
Example:
Input:
[2,7,11,15], target=9Output:
[0,1]Common Mistakes:
- Off-by-one indexing
- Not handling edge cases (null/empty)
Notes:
Edge cases: duplicates, empty inputs, negative numbers where applicable.
💻
Java Solution Hidden
Enable “Show Full Solution” to view the code
Use a hashmap to store complements and return indices when found.
Example:
Input:
[2,7,11,15], target=9Output:
[0,1]Common Mistakes:
- Off-by-one indexing
- Not handling edge cases (null/empty)
Notes:
Edge cases: duplicates, empty inputs, negative numbers where applicable.
1/75
Two Sum