From fcb5c66266d027a0551e111187c4969286ea00d9 Mon Sep 17 00:00:00 2001 From: Keqi Huang Date: Sun, 7 Apr 2019 15:50:57 +0800 Subject: [PATCH] Update 0208._implement_trie_(prefix_tree).md --- .../0208._implement_trie_(prefix_tree).md | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/docs/Leetcode_Solutions/Python/0208._implement_trie_(prefix_tree).md b/docs/Leetcode_Solutions/Python/0208._implement_trie_(prefix_tree).md index 8ee06db..d4afd93 100644 --- a/docs/Leetcode_Solutions/Python/0208._implement_trie_(prefix_tree).md +++ b/docs/Leetcode_Solutions/Python/0208._implement_trie_(prefix_tree).md @@ -1,13 +1,39 @@ -### 208. Implement Trie (Prefix Tree) +# 208. Implement Trie (Prefix Tree) -题目: +**难度: Medium** - +## 刷题内容 +> 原题连接 -难度: +* https://leetcode.com/problems/implement-trie-prefix-tree/ -Medium +> 内容描述 + +``` + +Implement a trie with insert, search, and startsWith methods. + +Example: + +Trie trie = new Trie(); + +trie.insert("apple"); +trie.search("apple"); // returns true +trie.search("app"); // returns false +trie.startsWith("app"); // returns true +trie.insert("app"); +trie.search("app"); // returns true +Note: + +You may assume that all inputs are consist of lowercase letters a-z. +All inputs are guaranteed to be non-empty strings. +``` + +## 解题方案 + +> 思路 1 +******- 时间复杂度: O(N)******- 空间复杂度: O(N)****** 这个Python实现也太精美了吧,谷歌复写之 -- GitLab