forked from moranzcw/LeetCode-NOTES
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.cpp
More file actions
29 lines (29 loc) · 697 Bytes
/
Copy pathsolution.cpp
File metadata and controls
29 lines (29 loc) · 697 Bytes
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
class Solution
{
public:
int maxProduct(vector<string>& words)
{
vector<int> bitmap(words.size(),0);
for(int i=0;i<words.size();i++)
{
for(int j=0;j<words[i].size();j++)
{
bitmap[i] |= 1<<(words[i][j]-'a');
}
}
int max = 0;
int temp;
for(int i=0;i<words.size();i++)
{
for(int j=i+1;j<words.size();j++)
{
if( (bitmap[i] & bitmap[j]) == 0)
{
temp = words[i].size()*words[j].size();
max = temp>max?temp:max;
}
}
}
return max;
}
};