Skip to content

Commit 6e55c5d

Browse files
committed
refactor(algorithms): three sum
1 parent c861e0d commit 6e55c5d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed
File renamed without changes.

algorithms/arrays/three_sum/__init__.py renamed to algorithms/two_pointers/three_sum/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
def three_sum(nums: List[int]) -> List[List[int]]:
55
"""
66
Complexity Analysis:
7-
Time Complexity: O(nlogn) + O(n^2) = O(n^2) the O(nlogn) is due to sorting
7+
8+
Time Complexity: O(nlog(n)) + O(n^2) = O(n^2) the O(nlog(n)) is due to sorting
89
Space Complexity: O(1) as no extra space is taken up
9-
@param nums: input list of integers
10-
@return: lists of lists of integers
10+
11+
Args:
12+
nums (list): input list of integers
13+
Return:
14+
list: list of lists of integers
1115
"""
1216
result = []
13-
# Time Complexity: O(nlogn)
17+
# Time Complexity: O(nlog(n))
1418
nums.sort()
1519

1620
for idx, num in enumerate(nums):

algorithms/arrays/three_sum/test_three_sum.py renamed to algorithms/two_pointers/three_sum/test_three_sum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22

3-
from algorithms.arrays.three_sum import three_sum
3+
from algorithms.two_pointers.three_sum import three_sum
44

55

66
class ThreeSumTestCases(unittest.TestCase):

0 commit comments

Comments
 (0)