package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
1. Two Sum
Solution idea
Use map
whose key
stores array elements and value
stores corresponding index.
Loop through the input array: if the complement (target - num
) of the current num
exists in the map
, return their indices.
Otherwise, store current element and its index into the map.
Time complexity = $O(n)$