leetcode2 C++ 1. Two Sum(Leet Code) Leet Code_1. Two Sum https://leetcode.com/problems/two-sum/ 문제 해석 이 문제를 풀기위해 이해해야 할 내용은 다음과 같습니다. 목표 더해서 target 값이 되는 두개의 원소 찾기 방법 1. 더해서 target 값이 되는 두개의 원소 찾기 2. hash map을 사용한다. 결과 더해서 target 값이 되는 두개의 원소 찾기 통과한 코드 그냥 순회하면서 찾는 코드 class Solution { public: vector twoSum(vector& nums, int target) { vector res; for(int i = 0 ; i < nums.size() ; i++) { for(int j = i+1 ; j 2020. 6. 22. C++ 11. Container With Most Water(Leet Code) Leet Code_11. Container With Most Water Dynamic Programming https://leetcode.com/problems/container-with-most-water/ 문제 해석 이 문제를 풀기위해 이해해야 할 내용은 다음과 같습니다. 목표 각 라인 사이에서 물을 최대로 담을수 있는 수조의 크기 방법 1. 각 라인 사이에서 물을 최대로 담을수 있는 수조의 크기 결과 각 라인 사이에서 물을 최대로 담을수 있는 수조의 크기 Test Case는 다 통과했지만 시간 초과된 코드 class Solution { public: int maxArea(vector& height) { int nMax = 0; int nSize = height.size(); for(int i =.. 2020. 6. 17. 이전 1 다음