본문 바로가기

전체 글310

23] Leetcode 728. Self Dividing Numbers https://leetcode.com/problems/self-dividing-numbers/ Self Dividing Numbers - 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 범위 내 숫자들 중에 각 자릿수로 나눠 떨어지는 숫자의 개수를 반환하는 문제. 안 되는 숫자는 0을 포함하고 있거나, 나눠 떨어지지 않는 경우이다. 그 경우만 제외하고 vector에 넣어주면 된다. class Solution { public: vector selfDividingNu.. 2020. 7. 4.
22] Leetcode 1446. Consecutive Characters Consecutive Characters - 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 maxPower(string s) { int ans = 1; int startPoint = 0; char startChar= s[0]; for(int i = 1;i 2020. 7. 3.
21] Leetcode 657. Robot Return to Origin Robot Return to Origin - 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 judgeCircle(string moves) { int upDown = 0; int leftRight =0; for(int i = 0;i 2020. 7. 1.
20] Leetcode 1450. Number of Students Doing Homework at a Given Time Number of Students Doing Homework at a Given Time - 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 busyStudent(vector& startTime, vector& endTime, int queryTime) { int ans =0; for(int i = 0;i 2020. 7. 1.
19★] Leetcode 1436. Destination City 최종 목적지를 반환하는 문제. Destination City - 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 양 끝점만 한번 나오고 나머지 city는 두 번씩 나오니까 한 번만 나오는 city 중에 목적지에 있는 city를 반환하는 문제. class Solution { public: string destCity(vector& paths) { // 한번나오고 뒤에 배치되어있는 문자열 반환 map words; map::iterator it; for(int i = .. 2020. 6. 30.
18] Leetcode 1475. Final Prices With a Special Discount in a Shop Final Prices With a Special Discount in a Shop - 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문 돌면서 다음 숫자부터 마지막까지 숫자들 중에 for문의 숫자보다 더 작은 게 있는지 확인하는 문제. class Solution { public: vector finalPrices(vector& prices) { vector ans; bool flag = false; for(int i = 0;i 2020. 6. 29.