본문 바로가기

알고리즘7

Stack 대표 문제 풀기 이번 포스트에서는 Stack과 관련된 문제를 풀어보겠습니다. 풀이는 코드에 직접 적었습니다. 혹시나 궁금하신 부분이 있으시면 댓글로 문의 부탁드립니다. 1. Valid Parentheses Valid 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: bool valid(char & c, stack & st) { if (st.empty()) { return false; } if (c == ').. 2022. 11. 1.
Sliding Window 대표 문제 풀기 이번 포스트에서는 Sliding Window와 관련된 문제를 풀어보겠습니다. 풀이는 코드에 직접 적었습니다. 혹시나 궁금하신 부분이 있으시면 댓글로 문의 부탁드립니다. 1. Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock - 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 maxProfit(vector& prices) { // 이전에 나온 최.. 2022. 10. 31.
Two pointers 대표 문제 풀기 이번 포스트에서는 Two pointers 기법으로 풀 수 있는 대표 문제를 풀어보도록 하겠습니다! 문제풀이는 C++로 진행하겠습니다. 1. 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 풀이 class Solution { public: bool isPalindrome(string s) { // 불필요한 문자열을 제거한 최종 결과물을 저장합니다. string filtered = ""; for (aut.. 2022. 10. 31.
배열과 해시 대표 문제 풀기 이번 포스트에서는 leetcode에 있는 Array 와 Hashing의 대표 문제들을 풀어보겠습니다. 문제풀이는 편의상 C++로 진행하겠습니다. 1. Containers Duplicates [Easy] Contains Duplicate - 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 containsDuplicate(vector& nums) { // 이전에 나온 값을 저장하기 위해서 HashMap을 준비.. 2022. 10. 30.