2025/01/07 4

96. Unique Binary Search Trees

96. Unique Binary Search Trees class Solution: def numTrees(self, n: int) -> int: # DP 배열 초기화 (Initialize the DP array) # dp[i]: i개의 노드를 사용하여 만들 수 있는 고유한 BST의 개수 # dp[i]: Number of unique BSTs that can be formed using i nodes dp = [0] * (n + 1) dp[0] = 1 # 빈 트리의 경우, 가능한 BST는 1개 (Empty tree has one valid BST) dp[1] = 1 # 노드가 1개인 경우, 가능한 BST는 1개 (One ..

LeetCode/DP심화 2025.01.07

문자열 심화: Naive String Matching (4)과 Boyer-Moore 알고리즘 (7)

Naive String Matching 관련 문제28. Find the Index of the First Occurrence in a String (strStr) (Easy)설명: 주어진 두 문자열에서 특정 패턴 문자열의 시작 인덱스를 반환합니다.핵심 개념: 문자열 비교, Naive String Matching.796. Rotate String (Easy)설명: 두 문자열이 주어졌을 때, 하나를 회전하여 다른 문자열을 만들 수 있는지 확인합니다.핵심 개념: Naive 문자열 비교.415. Add Strings (Easy)설명: 두 문자열로 표현된 숫자를 더한 결과를 반환합니다.핵심 개념: Naive 문자열 처리, 수학.242. Valid Anagram (Easy)설명: 두 문자열이 애너그램인지 확인합니다..

문자열 심화: Trie 트라이 문제 (19)

가장 긴 접두어 찾기 관련 문제14. Longest Common Prefix (Easy)설명: 문자열 배열에서 가장 긴 공통 접두사를 찾습니다.핵심 개념: 문자열 비교, 정렬.648. Replace Words (Medium)설명: 문장의 단어를 사전에 있는 가장 짧은 접두사로 대체합니다.핵심 개념: Trie, 문자열 처리.745. Prefix and Suffix Search (Hard)설명: 특정 접두사와 접미사로 시작/끝나는 단어를 찾습니다.핵심 개념: Trie, 해시맵.28. Find the Index of the First Occurrence in a String (strStr) (Easy)설명: 특정 패턴 문자열의 시작 인덱스를 반환합니다.핵심 개념: KMP 알고리즘, 문자열 비교.214. Sho..