알고리즘 문제풀이/[C++] Leetcode

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 125번 Valid Palindrome

문제 출처:https://leetcode.com/problems/valid-palindrome/ Valid Palindrome - 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 문제 분석 말 그대로 non-alphanumeric 영문자가 아닌 글자들을 제외한 문자열을 소문자로 둘때, 양쪽이 종이접듯이 같은 배열을 가지고 있으면 true 그렇지 않다면 false를 출력하는 문제입니다. c++에서는 isalpha와 isdigit라는 함수를 지원해주는데 각각 알파벳인..

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 412번 Fizz Buzz

문제 출처:https://leetcode.com/problems/fizz-buzz/ Fizz Buzz - 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 문제 분석 3으로 나누어 떨어지면 Fizz를 5로 나누어 떨어지면 Buzz를 출력하는 문제입니다. 코드는 다음과 같습니다: class Solution { public: vector fizzBuzz(int n) { vector answer ; for(int i = 1 ; i

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 1154번 Day of the Year

문제 출처:https://leetcode.com/problems/day-of-the-year/ Day of the Year - 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 문제 분석 1900년 1월 1일부터 2019년 12월 31일까지 중 input으로 주어진 날짜가 그 해의 몇번째 되는 날인지를 출력하면 되는 문제입니다. 각 달은 1월부터 12월까지 31,28,31,30,31,30,31,31,30,31,30,31를 반복한다는 규칙을 가지고 있습니다. 총합은 ..

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 682번 Baseball Game

문제 출처:https://leetcode.com/problems/baseball-game/ Baseball Game - 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 calPoints(vector& ops) { vector v; for (const auto& op : ops) { if (op == "+") { v.emplace_back(v[v.size() - 2] + v.back());..

알고리즘 문제풀이/[C++] Leetcode

Leetcode 문제 1047번 Remove All Adjacent Duplicates In String

문제 출처:https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/ Remove All Adjacent Duplicates In String - 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 문제 분석 이 문제는 Input으로 주어진 문자열 s에 인접하게 중복된 단어들을 제거한 문자열을 출력하는 문제입니다. ${O(n^2)}으로도 구현할 수 있었으나, 시간복잡도가 더 짧은 것이 시간 초과가 ..

gurcks8989
'알고리즘 문제풀이/[C++] Leetcode' 카테고리의 글 목록