Rust | bitmask | 0ms | beats 100%
Intuition\nEncode chars in a bitmask from 0-25 bits and check if there are matches.\n\n# Approach\nFor each word create a mask of the chars that are present in 
# Intuition\nEncode chars in a bitmask from 0-25 bits and check if there are matches.\n\n# Approach\nFor each word create a mask of the chars that are present in it. This creates a number which indicates which alphabet is present in that word. Similar strings will have same mask.\n\n# Complexity\n- Time complexity: $$O(n^2 + n|word|)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nimpl Solution {\n    pub fn similar_pairs(words: Vec<String>) -> i32 {\n        let mut wb = words.iter().map(|w| {\n            let mut mask = 0;\n            for b in w.clone().into_bytes() {\n                mask |= 1 << (b - b\'a\');\n            }\n            mask\n        }).collect::<Vec<_>>();\n        let mut ans = 0;\n        for i in 0..wb.len()-1 {\n            for j in i+1..wb.len() {\n                if wb[i] == wb[j] {\n                    ans += 1;\n                }\n            }\n        }\n        ans\n    }\n}\n```
['Rust']