Algorithm
[LeetCode] 1700. Number of Students Unable to Eat Lunch (Daily Question)
문제 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 in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step: - If the student at the front of the queue prefers the ..
[LeetCode] 678. Valid Parenthesis String (Daily Question)
문제 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 ')' must have a corresponding left parenthesis '('. - Left parenthesis '(' must go before the corresponding right parenthesis ')'.'*' - could be tr..
[LeetCode] 1249. Minimum Remove to Make Valid Parentheses (Daily Question)
문제 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 valid string. Formally, a parentheses string is valid if and only if: - It is the empty string, contains only lowercase characters, or - It can be written as AB (A concatenated..
[LeetCode] 10. Regular Expression Matching
문제 Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: - '.' Matches any single character. - '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). 문자열 s와 패턴 p가 주어졌을 때, s가 p에 매칭되는지 확인하는 문제이다. 패턴에서 "."은 아무 문자 하나, "*"은 앞의 문자 반복(0, 1 포함)을 의미한다. 풀이 아이디어 ".", "*"이 정규표현식과 같은 ..
[LeetCode] 1544. Make The String Great (Daily Question)
문제 Given a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where: - 0 "aAcC" --> "cC" --> "" 예시를 보면 없애야 하는 부분을 없앴더니 새로운 부분이 생긴 것을 볼 수 있다. 풀이 아이디어 알파벳은 26개로, 같은 알파벳이 대소문자로 붙어있는 경우는 26*2(소문자+대문자, 대문자+소문자), 32가지 밖에 없다. 주어지는 문자열의 길이도 최대 100으로, 짧기 때문에 없애야 하는 부분을 미리 정의해 두고 문자열이 더 이상 바뀌지 않을 때까지 반복하면 좋은 문자열이 될 것이다. ..
![[LeetCode] 1111. Maximum Nesting Depth of Two Valid Parentheses Strings](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FGlaKQ%2FbtsGmMTD7E8%2FAAAAAAAAAAAAAAAAAAAAABJOZrvkbi9XU8ScWmKlZe2234JbkkfD2Xu6QRbjU6yi%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DnGUjZzDI6LdjVx2z9QIT7cDkpLo%253D)
[LeetCode] 1111. Maximum Nesting Depth of Two Valid Parentheses Strings
문제 A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only. Given a VPS seq, split it into two disjoint subsequences A and B, such that A and B are VPS's (and A.length + B.length = seq.length). Now choose any such A and B such that max(depth(A), depth(B)) is the minimum possible value. Return an answer array (of length seq.length) that encod..