We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 86b6982 commit 9372e4dCopy full SHA for 9372e4d
src/bin/maximum-product-of-word-lengths.rs
@@ -0,0 +1,27 @@
1
+fn main() {}
2
+
3
+struct Solution;
4
5
+impl Solution {
6
+ pub fn max_product(words: Vec<String>) -> i32 {
7
+ let mut v = vec![0i32; words.len()];
8
9
+ for i in 0..words.len() {
10
+ for &j in words[i].as_bytes() {
11
+ v[i] |= (1 << (j - b'a'));
12
+ }
13
14
15
+ let mut r = 0;
16
17
18
+ for j in i + 1..words.len() {
19
+ if (v[i] & v[j]) == 0 {
20
+ r = r.max(words[i].len() * words[j].len())
21
22
23
24
25
+ r as i32
26
27
+}
0 commit comments