916. Word Subsets Medium

@problem@discussion
#Array#Hash Table#String



1/**
2 * [916] Word Subsets
3 *
4 * You are given two string arrays words1 and words2.
5 * A string b is a subset of string a if every letter in b occurs in a including multiplicity.
6 * 
7 * 	For example, "wrr" is a subset of "warrior" but is not a subset of "world".
8 * 
9 * A string a from words1 is universal if for every string b in words2, b is a subset of a.
10 * Return an array of all the universal strings in words1. You may return the answer in any order.
11 *  
12 * Example 1:
13 * 
14 * Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
15 * Output: ["facebook","google","leetcode"]
16 * 
17 * Example 2:
18 * 
19 * Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
20 * Output: ["apple","google","leetcode"]
21 * 
22 *  
23 * Constraints:
24 * 
25 * 	1 <= words1.length, words2.length <= 10^4
26 * 	1 <= words1[i].length, words2[i].length <= 10
27 * 	words1[i] and words2[i] consist only of lowercase English letters.
28 * 	All the strings of words1 are unique.
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/word-subsets/
34// discuss: https://leetcode.com/problems/word-subsets/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn word_subsets(words1: Vec<String>, words2: Vec<String>) -> Vec<String> {
40        vec![]
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_916() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.