brute force 방식으로 풀었다.
어렵지 않게 이해할 수 있는 코드이다.
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        vector<int> v;
        for(int i = 0 ; i < nums.size() ; i++)
        {
            for(int j = i+1 ; j <=nums.size()-1 ; j++)
            {
                if(nums[i] + nums[j] == target)
                {
                    v.push_back(i);
                    v.push_back(j);
                    return v;
                }
            }
        }
        return v;
    }
};
운영중인 카톡방입니다.
https://open.kakao.com/o/gsMhUFie
C/C++/C# 언리얼/유니티 /질문
#C++#C#언리얼#게임개발#질문#개발#자료구조#백준#프로그래머스#c#유니티#unity#enreal
open.kakao.com
'LeetCode' 카테고리의 다른 글
| 796. Rotate String 문제 (0) | 2022.07.07 | 
|---|---|
| 28. Implement strStr() c++ (0) | 2022.07.07 | 
| 287. Find the Duplicate Number c++ 문제 풀이 (0) | 2022.07.03 | 
| 581. Shortest Unsorted Continuous Subarray c++ 문제 (0) | 2022.06.23 | 
| 162. Find Peak Element c++ 문제 (0) | 2022.06.21 | 
										
									
댓글