목록2024/01 (34)
넘치게 채우기
https://leetcode.com/problems/daily-temperatures/description/?envType=daily-question&envId=2024-01-31 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Daily Temperatures 문제 유형 : 스택, 모노토닉 스택 문제 난이도 : Medium 문제 Give..
https://leetcode.com/problems/evaluate-reverse-polish-notation/description/?envType=daily-question&envId=2024-01-30 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Evaluate Reverse Polish Notation 문제 유형 : 스택, 후위표..
스택은 LIFO, 큐는 FIFO 자료구조이다. 어떻게 하면 두 개의 스택으로 하나의 큐를 구현하는데, 대부분의 경우에서 O(1)으로 구현할 수 있을까? 하나를 입력용 스택, 하나를 출력용 스택이라고 해보자. 입력용 스택은 입력만 받는다. 출력용 스택은 출력만 한다. 단, 출력용 스택이 empty인 경우, 입력용 스택의 원소들을 pop하여 출력용 스택에 push하면 된다. 이때 출력용 스택에는 입력의 역순으로 들어오게 되어 기존의 출력 순서가 반대로 되어 FIFO가 된다. 이 경우만 제외하고는, O(1)의 시간복잡도를 가진다. class MyQueue { stack i,o; public: MyQueue() { } void push(int x) { i.push(x); } int pop() { int x; i..
https://leetcode.com/problems/implement-queue-using-stacks/description/?envType=daily-question&envId=2024-01-29 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Implement Queue using Stacks 문제 유형 : 스택/큐 문제 난이도 : E..
https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/description/?envType=daily-question&envId=2024-01-28 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Number of Submatrices That Sum to Target..
https://leetcode.com/problems/k-inverse-pairs-array/description/?envType=daily-question&envId=2024-01-27 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - K Inverse Pairs Array 문제 유형 : 순열, 조합, 수학, 마호니언 삼각형, 다이나믹 프로..
마호니언 숫자의 삼각형(또는 마호니언 삼각형)의 수들은 ∏(𝑖=0..𝑛−1)(1+𝑥+...+𝑥𝑖)를 전개했을 때의 각 계수이다. 코시 곱에 의해서 1부터 n까지의 순열에서 K번의 역전이 일어난 순열의 개수임이 증명된다. k는 해당하는 순열을 increasing order로 만들기 위한 버블정렬의 스왑 횟수와도 같다. 삼각형은 좌우대칭의 형태를 가진다. 순열의 무질서도와 정규 분포에도 관련이 있다. 공식 T(n, k)를 1부터 n까지의 순열에서 K번의 역전이 일어난 순열의 개수라고 하였을 때, 다음이 성립한다. T(1, 0) = 1, T(n, k) = 0 for n n*(n-1)/2. T(n, k) = Sum_{j=0..n-1} T(n-1, k-j) 정리하면, T(n, k)..
https://leetcode.com/problems/out-of-boundary-paths/description/?envType=daily-question&envId=2024-01-26 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Out of Boundary Paths 문제 유형 : 다이나믹 프로그래밍 문제 난이도 : Medium 문제..
https://leetcode.com/problems/longest-common-subsequence/description/?envType=daily-question&envId=2024-01-25 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Longest Common Subsequence 문제 유형 : 다이나믹 프로그래밍 / 재귀 문제 ..
https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree/description/?envType=daily-question&envId=2024-01-24 LeetCode - The World's Leading Online Programming Learning Platform 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 LeetCode - Pseudo-Palindromic Paths in a Binary Tr..