丢盒子OA和店面过经

我的解法如下:

Mapping each puzzle to the set of characters they contain:

vector<int> spellingBee(vector<string>& wordList, vector<string>& puzzles) {
    vector<vector<bool>> puzzle_map(puzzles.size(), vector<bool>(26));
    
    for (int i = 0; i < puzzles.size(); i++) {
        for (char c : puzzles[i]) {
            puzzle_map[i][c - 'A'] = true;
        }
    }
    
    vector<int> ans(puzzles.size(), 0);
    
    for (string& word : wordList) {
        for (int i = 0; i < puzzles.size(); i++) {
            int match_count = 0;
            bool key = false;
            for (char c : word) {
                if (puzzle_map[i][c - 'A']) match_count++;
                if (!key && puzzles[i][0] == c) key = true;
            }
            if (key && match_count == word.length()) ans[i]++;
        }
    }
    
    return ans;
}

void test(vector<string> wordList, vector<string> puzzles, vector<int> expected) {
    assert(spellingBee(wordList, puzzles) == expected);
}

int main() {
    test({"APPLE", "PLEAS", "PLEASE"}, {"AELWXYZ", "AELPXYZ", "AELPSXY", "SAELPXY", "XAELPSY"}, {0,1,3,2,0});
}
还有道看到的OA题我也帖一下
Auto-complete feature

Dropbox has tasked you with gathering some qualitative metrics regarding a simple text search auto-complete feature. You’ll be given a set of documents, each having a title and a body of text.

Every word in the documents can be assigned a numeric score. The score is defined as follows:

  • Each occurrence in the title: 10
  • Each occurrence in the body: 1

Note that the scores should be computed across all documents.

For example, given two documents

Title Body
Document A ANIMALS ANT ANTELOPE CAMEL CAT DOG
Document B DOG FACTS FURRY FURRY LOYAL
  • ANIMALS has a score of 10, because it appears once in a document’s title
  • CAT has a score of 1, because it appears once in a document’s body
  • DOG has a score of 11, because it appears once in a docurnent’s body, and once in a document’s title
  • FURRY has a score of 2, because it appears twice in a document’s body

You’ll then be given a set of user queries, each a string with no whitespace. For each query, compute the highest score among all the words that could be auto-completed from it. For instance, among the set of words above, the query ‘AN’ could be auto-completed into ANIMALS, ANT, and ANTELOPE. If no such words exist, the score is 0.

For example, given these following queries:

  • AN would output 10, because it can auto-complete into ANIMAL (which has a higher score than ANT and ANTELOPE)
  • DO would output 11, because it can auto-complete into DOG
  • FUR would output 2, because it can auto-complete into FURRY
  • ELEPH would output 0, because it cannot auto-complete into any of the words

You can assume text and queries are comprised of A-Z characters. In documents, words are separated by a space; there is no other whitespace.

Constraints

  • N: the number of documents 1 <= N < 1,000
  • Q: the number of queries 1 <= Q < 300,000

谢谢楼主的分享!请问楼主是海投的还是内推的?海投的话可以拿到OA嘛?谢谢

找朋友内推的

每个人不一样吧,跟简历有关

补充一下店面:

他们家好像真的只面题库里的题而且三年不变,跟我朋友去年面的时候是同样的题,

面经里面的找duplicate file,但是比leetcode那个难,因为要自己从call file api,然后检查duplicates,比leetcode那个str list input复杂。但总体思路差不多。

这题找不到一样的leetcode原题所以完全没准备,然后怎么读文件怎么读metadata怎么做MD5 hash的utils我全都不记得,现场各种发挥创造了假设各种utils。这个需要多跟面试官沟通,刚开始他只会给你一个root path的string,你说了思路然后具体问他可不可以用utils的时候他会给你再copy过来,比如说他后来给了我一下list folder, get path, md5 hasher之类的api用。

一周后接到通知约onsite!超级无敌激动终于可以体验一下加州第一食堂!我能说我投他家主要就是想去onsite蹭两轮饭么,主厨实在太优秀:

感谢楼主分享!请问楼主这个做法能过所有test case吗?我在别的地方看到有人说要用trie,而且简单的trie还过不了,要sort wordlist啥的,看起来好复杂。。。