Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int maxProduct(vector<string>& words) {
- unordered_map<int, int> maskLen;
- int ans = 0;
- for(auto word: words){
- int mask = 0;
- for(char ch: word)
- mask |= (1<<(ch-'a'));
- maskLen[mask] = max(maskLen[mask], int(word.length()));
- for(auto &mLen: maskLen)
- if(!(mask & mLen.first))
- ans = max(ans, int(mLen.second*word.length()));
- }
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement