3sum
-
[LeetCode] 15. 3SumLeetCode 2021. 10. 18. 16:40
https://leetcode.com/problems/3sum/ 3Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 3Sum int 배열(벡터)이 주어졌을때, 그 안에서 세 개를 더했을때 0 이 되는 조합을 모두 찾아내는 문제이다. 이 때, 조합은 중복이 되면 안된다. 2Sum 문제에서는 투 포인터를 이용해 문제를 해결한다. 먼저 배열을 오름차순으로 정렬한 후, 왼쪽끝과 오른쪽끝을 포인터로 두고, target보다 클 경우 오른쪽 포인터를 --, 작을 경우..