summaryrefslogtreecommitdiffstats
path: root/04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-11-14 06:35:05 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-14 06:47:32 +0100
commit45188449a04a1455ade01caf470e43a926d752aa (patch)
tree7ba811241977d4e10538bc15ac6ba3db34f4ed15 /04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp
parentd0ef4dff785e213cf3385ba2f29f316de048eb55 (diff)
downloadcoursera-45188449a04a1455ade01caf470e43a926d752aa.zip
coursera-45188449a04a1455ade01caf470e43a926d752aa.tar.gz
Algorithms : add 04-algorithms_on_strings 01-suffix_trees
Diffstat (limited to '04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp')
-rw-r--r--04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp b/04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp
new file mode 100644
index 0000000..08cfe9b
--- /dev/null
+++ b/04-algorithms_on_strings/01-suffix_trees/01-trie/trie.cpp
@@ -0,0 +1,37 @@
+#include <string>
+#include <iostream>
+#include <vector>
+#include <map>
+
+using std::map;
+using std::vector;
+using std::string;
+
+typedef map<char, int> edges;
+typedef vector<edges> trie;
+
+trie build_trie(vector<string> & patterns) {
+ trie t;
+ // write your code here
+ return t;
+}
+
+int main() {
+ size_t n;
+ std::cin >> n;
+ vector<string> patterns;
+ for (size_t i = 0; i < n; i++) {
+ string s;
+ std::cin >> s;
+ patterns.push_back(s);
+ }
+
+ trie t = build_trie(patterns);
+ for (size_t i = 0; i < t.size(); ++i) {
+ for (const auto & j : t[i]) {
+ std::cout << i << "->" << j.second << ":" << j.first << "\n";
+ }
+ }
+
+ return 0;
+} \ No newline at end of file