-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday11.cpp
More file actions
37 lines (28 loc) · 1.08 KB
/
day11.cpp
File metadata and controls
37 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Good morning! Here's your coding interview problem for today.
This problem was asked by Twitter.
Implement an autocomplete system. That is, given a query string s and a set of all possible query strings, return all strings in the set that have s as a prefix.
For example, given the query string de and the set of strings [dog, deer, deal], return [deer, deal].
Hint: Try preprocessing the dictionary into a more efficient data structure to speed up queries.
*/
#include <gtest/gtest.h>
#include <string>
using namespace std;
void find_word()
{
/*
Idea: I would use a tree data structure, a root is a letter and the branches are containing the
next letters. I think we can represent this structure using a dictionnary of dictionnaries
and preprocessing data. We can also have in each node an array of pointers to every word
existing as a leaf of the current node to save time
*/
}
TEST(FIND_WORDS, find_word)
{
const set<string> words = {"dog", "deer", "deal"};
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}