전체 글
-
[leetcode - Python] Roman to IntegerProblem Solving 2022. 7. 19. 14:29
문제 설명 https://leetcode.com/problems/roman-to-integer/submissions/ Roman to Integer - 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 난이도 - Medium 문자열로 주어지는 로마 숫자를 아라비아 숫자로 바꾸는 문제 접근 방법 기본적으로 알파벳을 만나면 해당 숫자를 더해주는데, 만난 알파벳보다 그 다음 알파벳이 더 크면 빼준다. 이때 주의해야할 점은, 문제 예시엔 I, X, C에 대한 총 6가지 예..
-
[leetcode - python] Majority ElementProblem Solving 2022. 7. 18. 17:11
문제 설명 https://leetcode.com/problems/majority-element/ Majority Element - 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 배열 중 과반수 이상 등장하는 수를 찾는 문제 난이도 - Easy 관련 개념 Boyer-Moore Voting Algorithm (보이어-무어 과반수 투표 알고리즘) : 인접한 두 수가 서로 다르다면 둘 다 버리는 개념의 알고리즘. 2개를 버리면 과반수가 1 줄어드므로 Majority E..
-
[leetcode - C] Maximum SubarrayProblem Solving 2022. 7. 16. 13:47
문제 설명 https://leetcode.com/problems/maximum-subarray/ Maximum Subarray - 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 난이도 - Medium 배열에서 연속된 수들 중 합이 가장 큰 조합을 찾는 문제 관련 개념 배열 접근 방법 패턴을 찾으면 구현은 어렵지 않은 문제. 배열의 요소를 앞에서부터 탐색하면서 현재 탐색하는 수를 Maximum Subarray에 포함할지 말지가 관건 이므로, (직전까지의 누적합+현..
-
[leetcode] 204. Count Primes - CProblem Solving 2022. 4. 14. 00:56
문제 https://leetcode.com/problems/count-primes/submissions/ Count Primes - 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 분류 - ? 난이도 - Medium 제약조건 - 0
-
[leetcode] 172. Factorial Trailing Zeroes - CProblem Solving 2022. 3. 12. 23:15
문제 Factorial Trailing Zeroes - 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 분류 - 브루트포스, ? 난이도 - Medium 문제 설명 n이 주어졌을 때, n! 값의 끝에 연속된 0이 몇 개 오는지 구하는 문제 즉, n! 값이 10으로 몇 번 나누어 떨어지는지 구하면 된다. 접근 방법 n!의 인수 중 10을 만드는 인수인 2와 5가 몇 번 등장하는지 구하고, 2의 개수와 5의 개수와 중 더 적은 개수가 답이 된다. 이때, 2는 모든 짝수..
-
[leetcode] 283. Move zeroes - CProblem Solving/? 2022. 3. 12. 00:00
문제 https://leetcode.com/problems/move-zeroes/ Move Zeroes - 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 분류 - ? 난이도 - Easy 제약조건 1
-
[leetcode] 136. Single Number - CProblem Solving/? 2022. 3. 11. 23:51
문제 https://leetcode.com/problems/single-number/ Single Number - 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 분류 - ? 난이도 - Easy 제약 1
-
[leetcode] 70. Climbing Stairs - CProblem Solving 2022. 3. 5. 13:57
분류 - 재귀 난이도 - Easy 문제 설명 (n층의 계단을 오르는 방법의 수)는 (n-1층을 오르는 방법의 수 + n-2층을 오르는 방법의 수)와 같다. 예를 들어, 4층을 오른다고 하면 3층까지 오르는 경우의 수를 먼저 구하고, 3층을 계단 한 층으로 생각하여 계단 두 층을 오르는 경우의 수를 더하면 되는 것이다. 답안 코드 1. 재귀 연산 메모리: 5.4 MB , 시간: 2 ms int climbStairs(int n){ int a=0, b=1, c; # 0층을 오르는 방법의 수, 1층을 오르는 방법의 수, n층을 오르는 방법의 수 for(int i=0;i