1. 문제https://leetcode.com/problems/valid-palindrome/description/?envType=study-plan-v2&envId=top-interview-150 2. 요구사항1) 팰린드롬은 모든 대문자를 소문자로 바꾸고, 모든 영숫자가 아닌 문자를 제거한 후, 앞뒤로 읽어도 같은 구문이다.2) 문자열 s가 주어진 후, 팰린드롬이면 true를 반환하고, 아니면 false를 반환한다. 3. 핵심 아이디어1) 문자열 전처리 후, 문자 비교 주어지는 문자열에는 공백과 특수 문자가 있으며, 대문자와 소문자가 나누어져 있다.이를 순수한 소문자 문자열로 바꾸기 위해 전처리 과정을 거친다.String result = s.replaceAll(RegExp('[^a-zA-Z0-9]..
1. 문제 https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/?envType=study-plan-v2&envId=top-interview-150 2. 요구사항1) 주식 가격이 작성된 prices 배열 주어진다.2) 주식을 한 번 사고 한 번 팔아서 얻을 수 있는 최대 이익을 계산한다.3) 이익을 얻을 수 없는 경우에는 0을 반환한다. 3. 핵심 아이디어1) 최소 가격을 추적하고, 최대 이익 계산prices 배열에서 가장 싼 가격(minPrice)을 추적한다. 배열을 왼쪽에서 오른쪽으로 순회하며 현재 가격 - minPrice 를 계산해서 현재 시점에서 얻을 수 있는 이익을 구한다. 그 이익이 지금까지 본 최대 이익보다 ..
1. LeetCode 풀이 https://sfida.tistory.com/85 [Dart] 104. Maximum Depth of Binary Tree1. 문제https://leetcode.com/problems/maximum-depth-of-binary-tree/description/?envType=study-plan-v2&envId=leetcode-75 2. 요구사항1) 이진 트리의 루트 노드가 주어졌을 때, 이 트리의 최대 깊이를 구한다. 3. 핵심 아sfida.tistory.com 2. 개인 과제 제출 https://github.com/Meezzi/console-rpg-game GitHub - Meezzi/console-rpg-gameContribute to Meezzi/console-r..
1. 문제https://leetcode.com/problems/maximum-depth-of-binary-tree/description/?envType=study-plan-v2&envId=leetcode-75 2. 요구사항1) 이진 트리의 루트 노드가 주어졌을 때, 이 트리의 최대 깊이를 구한다. 3. 핵심 아이디어1) 재귀적 접근각 노드의 왼쪽 노드와 오른쪽 노드의 깊이를 각각 구한 후, 그 중 더 큰 깊이에 1을 더하여 반환한다. 2) 코드class Solution { int maxDepth(TreeNode? root) { // root가 null이면 종료 if(root == null) { return 0; } // 오른쪽 노드의 깊이 구하기 int..