标签:
- G: a vector of strings, find a pair with max of strlen(a) * strlen(b)
1. O(n*k): get std::bitset() of each string
2. O(nlgn): sort strings by length
3. O(n^2): loop from longest. Pruning: record current max strlen(a)*strlen(b), will not check any strlen(c) * strlen(d) < strlen(a) * strlen(b)
Or: http://www.quora.com/Given-a-dictionary-of-words-how-can-we-efficiently-find-a-pair-words-s-t-they-dont-have-characters-in-common-and-sum-of-their-length-is-maximum
标签:
原文地址:http://www.cnblogs.com/tonix/p/4231574.html