mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Update data_structures/arrays/two_sum.rb
This commit is contained in:
parent
bdee1f9277
commit
de9a06bc26
1 changed files with 4 additions and 1 deletions
|
@ -26,7 +26,10 @@
|
|||
#
|
||||
# Approach 1: Brute Force with Addition
|
||||
#
|
||||
# Time Complexity: O(N^2), where N is the length of the array
|
||||
# Time Complexity: O(n^2). For each element, we try to find its complement
|
||||
# by looping through the rest of the array which takes O(n) time.
|
||||
# Therefore, the time complexity is O(n^2)
|
||||
# Space complexity: O(1)
|
||||
#
|
||||
def two_sum(nums, target)
|
||||
result_array = []
|
||||
|
|
Loading…
Reference in a new issue