Skip to content

Commit bb37caa

Browse files
committed
add improvement point
1 parent f57e503 commit bb37caa

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

two-sum/acious.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Solution {
22
// nums의 모든 숫자를 Map에 저장. key는 nums의 숫자, value는 해당 숫자의 인덱스
33
// target의 숫자가 동일한 숫자가 더해져야 하는 케이스 (예: target = 4, nums = [2, 2])를 위해 value는 List로 저장
44
// 시간복잡도: O(n), 공간복잡도: O(n)
5+
// improvement point : 한번의 루프를 순회하는 것으로도 문제를 해결할 수 있음.
56
fun twoSum(nums: IntArray, target: Int): IntArray {
67
val map = mutableMapOf<Int, MutableList<Int>>()
78
for (index in nums.indices) { // nums.indices는 nums의 인덱스 범위를 반환

0 commit comments

Comments
 (0)