Update data_structures/arrays/two_sum.rb

This commit is contained in:
Vitor Oliveira 2021-03-11 21:22:39 -08:00 committed by GitHub
parent bdee1f9277
commit de9a06bc26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 = []