Skip to content

Commit 585e7fd

Browse files
committed
Add understanding of Trie implementation problem
1 parent b92c6ba commit 585e7fd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Constraints:
3+
1. 1 <= word.length, prefix.length <= 2000
4+
2. word and prefix consist only of lowercase English letters.
5+
3. At most 3 * 10^4 calls in total will be made to insert, search, and startsWith.
6+
7+
Time Complexity:
8+
-
9+
10+
Space Complexity:
11+
-
12+
13+
μ΄ν•΄ν•œ λ‚΄μš©:
14+
1. Prefix(접두사)의 의미
15+
- 문법적 접두사(un-, pre- λ“±)κ°€ μ•„λ‹˜, λ‹¨μˆœνžˆ λ‹¨μ–΄μ˜ μ•žλΆ€λΆ„μ— μžˆλŠ” λ¬Έμžμ—΄μ„ 의미
16+
- 예: "apple"의 접두사 -> "a", "ap", "app", "appl", "apple"
17+
18+
2. μ‹€ν–‰ 방식
19+
- μž…λ ₯으둜 μ£Όμ–΄μ§„ λͺ…λ Ήμ–΄λ₯Ό 순차적으둜 μ‹€ν–‰
20+
- 예: ["Trie", "insert", "search"] μˆœμ„œλŒ€λ‘œ μ‹€ν–‰
21+
- 각 λͺ…령어에 ν•΄λ‹Ήν•˜λŠ” μΈμžκ°’λ„ μˆœμ„œλŒ€λ‘œ 적용
22+
23+
3. 자료ꡬ쑰 선택
24+
- Trie의 각 λ…Έλ“œμ—μ„œ μžμ‹ λ…Έλ“œλ₯Ό μ €μž₯ν•  λ•Œ ν•΄μ‹œ ν…Œμ΄λΈ” μ‚¬μš©
25+
- ν‚€: λ‹€μŒ 문자, κ°’: ν•΄λ‹Ή 문자의 TrieNode
26+
- μž₯점: λ‹€μŒ 문자 검색이 O(1)둜 κ°€λŠ₯
27+
"""

0 commit comments

Comments
Β (0)