360 of the Headquarters was located near Wangjing 798 in Beijing. A friend went to the interview this week and gave a general talk about the process.
360 there is a lobby on the first floor of the headquarters, and there are a lot of MM at the front desk, indicating the intention. It is directed to the interview area (there are quite a lot of people, there should be very few people, or there should be new projects ).
Side:
Technically, he is a younger brother.
1) Introduce Yourself
2) I spoke about several important projects and asked about the projects. These are all topics of interest to the interviewer.
3) a programming question is given: design a trie tree to create a trie tree and search functions. The data is a batch of English words, all of which are lowercase letters.
Analysis:
This topic mainly involves three aspects: design the data structure of the trie tree, implement the trie tree creation function, and search for English words to see if they exist.
The implementation is as follows:
#include<iostream>#include<string.h>using namespace std;#define MAXNODE 26struct TrieNode{ int counts; TrieNode* next[MAXNODE];//next character TrieNode():counts(1){ int i = 0; while(i < MAXNODE) { next[i++] = NULL; } }};void createTrie(TrieNode* &root, char* str){ if(strlen(str) <= 0) return; if(root == NULL) root = new TrieNode(); int i = 0; TrieNode* p = root; while(i < strlen(str)) { int k = str[i++] - 'a'; if(p->next[k]) { p->next[k]->counts ++; } else p->next[k] = new TrieNode(); p = p->next[k]; }}int SearchTrie(TrieNode* root, char* str){ TrieNode* p = root; if(p == NULL) return -1; int i = 0; while(i < strlen(str)) { int k = str[i++] - 'a'; if(p->next[k] == NULL) return 0; else p = p->next[k]; if(i == strlen(str)) return p->counts; }}int main(){ char a[][4] = {"abc", "bcd", "ade", "acd", "bgf"}; int i = 0; int j = 0; TrieNode* root = NULL; while(i < 5) { createTrie(root, a[i++]); } char* b = "bcd"; int in = SearchTrie(root, b); if( in <= 0) cout << "Trie can't find \"" << b << "\"" << endl; else cout << "Trie have find \"" << b << "\"" << endl; return 0;}
Output result:
Trie have find "bcd"
Summary:
This algorithm can be used for string prefix queries, such as searching TIPS.