목록PS/LeetCode (370)
넘치게 채우기
https://leetcode.com/problems/add-one-row-to-tree/description/ LeetCode - Add One Row to Tree 문제 유형 : 이진트리, dfs, 재귀 문제 난이도 : Medium 문제 Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Given the integer depth, for each not null tree node cur at the depth depth - 1,..
https://leetcode.com/problems/sum-root-to-leaf-numbers/description/ Leetcode - Sum Root to Leaf Numbers 문제 유형 : dfs, 이진트리 문제 난이도 : Medium 문제 You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123. Return the total sum of all root-to-leaf numbers. T..
https://leetcode.com/problems/sum-of-left-leaves/description/ Leetcode - Sum of Left Leaves 문제 유형 : 이진 트리, dfs, 재귀 문제 난이도 : Easy 문제 Given the root of a binary tree, return the sum of all left leaves. A leaf is a node with no children. A left leaf is a leaf that is the left child of another node. 이진 트리의 루트가 주어진다. 모든 왼쪽 잎 노드의 값의 합을 구하시오. 잎 노드란 자식 노드가 없는 노드를 말합니다. 풀이 말 그대로 이진트리를 순회하면서 왼쪽 리프노드의 합을 반..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/DLgl2/btsGBRuuDau/3VGkIZVHkY6vPASkSbr0z0/img.png)
https://leetcode.com/problems/maximal-rectangle/description/ Leetcode - Maximal Rectangle 문제 유형 : 히스토그램, 스택, 다이나믹 프로그래밍 문제 난이도 : Hard 문제 Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. rows x cols크기의 이진 행렬이 주어진다. 1로만 이루어진 가장 큰 직사각형을 찾아서 그 크기를 반환하시오. 풀이 풀이 1: 다이나믹 프로그래밍(동적계획법) 처음에는 각 자리별로 1로 이어진 왼쪽 끝과 위쪽 끝을 구한 뒤, 크기를 일..
https://leetcode.com/problems/remove-k-digits/description/ Leetcode - Remove K Digits 문제 유형 : 스택 문제 난이도 : Medium 문제 Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. 양의정수를 표현하는 문자열 num이 주어집니다. num에서 k개의 정수를 제거한 가장 작은 수를 구하시오. 풀이 스택을 이용하여 풀 수 있다. 수를 하나씩 스택에 담는다. 만약에 이번에 넣을 수보다 큰 수들이 있다면, 그 수들은 기존 스택에서..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/oJMm2/btsGuJ5aGX2/n8KDjm0C44zidJRuzIS08k/img.png)
https://leetcode.com/problems/reveal-cards-in-increasing-order/description/ Leetcode - Reveal Cards In Increasing Order 문제 유형 : 스택, 큐 문제 난이도 : Medium 문제 You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i]. You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in o..
https://leetcode.com/problems/time-needed-to-buy-tickets/description/ LeetCode - Time Needed to Buy Tickets 문제 유형 : 큐 문제 난이도 : Easy 문제 There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line. You are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person ..
https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/description/ Leetcode - Number of Students Unable to Eat Lunch 문제 유형 : 스택, 큐 문제 난이도 : Easy 문제 The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches. The number of sandwiches ..
https://leetcode.com/problems/valid-parenthesis-string/submissions/1225282138/ Leetcode - Valid Parenthesis String 문제 유형 : 문자열 처리, 스택 문제 난이도 : Medium 문제 Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: Any left parenthesis '(' must have a corresponding right parenthesis ')'. Any right parenthesis '..
https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/description/ Leetcode - Minimum Remove to Make Valid Parentheses 문제 유형 : 문자열 처리 / 스택 문제 난이도 : Medium 문제 Given a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any vali..