diff --git a/data_structures/arrays/two_sum.rb b/data_structures/arrays/two_sum.rb index efc8fd6..318ee7f 100644 --- a/data_structures/arrays/two_sum.rb +++ b/data_structures/arrays/two_sum.rb @@ -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 = []