From d2f8f59f294393863aa7c8dfecfda6c7a54d9ca0 Mon Sep 17 00:00:00 2001 From: nguyenanh-cs Date: Tue, 23 Jul 2024 23:25:37 +0700 Subject: [PATCH] 2207 - Two Sum /* Excuse me for my broken English. To get the given result, we need to add two values of the given vector and compare the result with the target number. To do so, we first need to have a compared value and other comparing values. So first, we will initialize two initializers i and j. i is the compared value, and j is the comparing one. When i = 0, j = 1. These are indexes of the value in vector nums. We add these two values and compare the result with the target number. Continue through the similar process until the computer finds those that combine and equate the value to the target number. Then I return the result. */ // I know this solution will take much time and space complexity, so I have found some other solutions like Hashmap. I will learn more about this and solve this practice in another way. /* Calculate the Time Complexity and Space Complexity Time complexity: O(n) Space complexity: O(n^2) */