aboutsummaryrefslogtreecommitdiff
path: root/max_len_concat_str.rs
diff options
context:
space:
mode:
Diffstat (limited to 'max_len_concat_str.rs')
-rw-r--r--max_len_concat_str.rs29
1 files changed, 0 insertions, 29 deletions
diff --git a/max_len_concat_str.rs b/max_len_concat_str.rs
deleted file mode 100644
index 8ce0c2b..0000000
--- a/max_len_concat_str.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-struct Solution;
-
-impl Solution {
- pub fn max_length(arr: Vec<String>) -> i32 {
- let mut ans: u32 = 0;
- let mut unique: Vec<u32> = Vec::new();
- for s in arr {
- let bin: u32 = s.bytes().map(|c| 1 << (c - b'a')).sum();
- if bin.count_ones() == s.len() as u32 {
- unique.push(bin);
- }
- }
- let mut concat: Vec<u32> = vec![0];
- for u in unique {
- for i in 0..concat.len() {
- if (concat[i] & u).count_ones() == 0 {
- concat.push(concat[i] | u);
- ans = ans.max(concat[i].count_ones() + u.count_ones());
- }
- }
- }
- ans as i32
- }
-}
-
-fn main() {
- let arr = vec!["un".to_string(),"iq".to_string(),"ue".to_string()];
- print!("{}", Solution::max_length(arr));
-}