MCPcopy Create free account
hub / github.com/algorithm004-01/algorithm004-01 / twoSum

Function twoSum

Week 01/id_236/LeetCode_1_236.go:20–35  ·  view source on GitHub ↗

Solution 1: Brute-Force Use two loops to search the right pair. Time Complexity : O(n^2) Space Complexity: O(1) Solution 2: Sort and Search Sort the copied nums[O(NlogN)], and use two pointers start/end to search the pair[O(N)]. And search the indices in the original array. Time Complexity : O(NlogN

(nums []int, target int)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected