본문 바로가기

전체 글310

29★] Leetcode 1013. Partition Array Into Three Parts With Equal Sum https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/ Partition Array Into Three Parts With Equal Sum - 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 int 벡터를 공백이 아니고 합이 같은 세 개의 부분 배열로 나눌 수 있는지 묻는 문제. class Solution { public: bool canThreePartsEqualSum(vec.. 2020. 7. 7.
28] Leetcode 1021. Remove Outermost Parentheses https://leetcode.com/problems/remove-outermost-parentheses/ Remove Outermost Parentheses - 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 바깥 괄호를 제거하는 문제다. (일때 시작하는 괄호인지 )일때 마지막 괄호인지를 확인하면 된다, class Solution { public: string removeOuterParentheses(string S) { string ans = ""; int c.. 2020. 7. 6.
27] Leetcode 1266. Minimum Time Visiting All Points https://leetcode.com/problems/minimum-time-visiting-all-points/ Minimum Time Visiting All Points - 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 가로로 세로로, 대각선으로 한 칸씩 갈 수 있기 때문에 가로, 세로의 차 중에 큰 값으로 더 해주면 된다. class Solution { public: int minTimeToVisitAllPoints(vector& points) { int .. 2020. 7. 6.
26★] Leetcode 1491. Average Salary Excluding the Minimum and Maximum Salary Average Salary Excluding the Minimum and Maximum Salary - 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 1. 문제를 똑바로 이해하고 2. 반환값이 int인지 double인지 확인하고 class Solution { public: double average(vector& salary) { sort(salary.begin(), salary.end()); double total = 0.0; for(int i = 1;i 2020. 7. 5.
25★] Leetcode 1496. Path Crossing https://leetcode.com/problems/path-crossing/ 방향을 가리키는 문자열을 따라 이동했을 때 같은 점은 두 번 지나가는지 묻는 문제. Path Crossing - 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 for문으로 원점을 처음부터 하나씩 바꿔가면서 다시 원점으로 돌아가는지 확인한다. class Solution { public: bool isPathCrossing(string path) { bool ans = false; in.. 2020. 7. 5.
24] Leetcode 1502. Can Make Arithmetic Progression From Sequence Can Make Arithmetic Progression From Sequence - 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 먼저 정렬해주고, 간격 일정한지 판단. class Solution { public: bool canMakeArithmeticProgression(vector& arr) { sort(arr.begin(),arr.end()); bool flag = true; int diff = arr[1]-arr[0]; for(int i = 2;i 2020. 7. 5.