349. Intersection of Two Arrays Easy

@problem@discussion
#Array#Hash Table#Two Pointers#Binary Search#Sorting



1/**
2 * [349] Intersection of Two Arrays
3 *
4 * Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.
5 *  
6 * Example 1:
7 * 
8 * Input: nums1 = [1,2,2,1], nums2 = [2,2]
9 * Output: [2]
10 * 
11 * Example 2:
12 * 
13 * Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
14 * Output: [9,4]
15 * Explanation: [4,9] is also accepted.
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	1 <= nums1.length, nums2.length <= 1000
21 * 	0 <= nums1[i], nums2[i] <= 1000
22 * 
23 */
24pub struct Solution {}
25
26// problem: https://leetcode.com/problems/intersection-of-two-arrays/
27// discuss: https://leetcode.com/problems/intersection-of-two-arrays/discuss/?currentPage=1&orderBy=most_votes&query=
28
29// submission codes start here
30
31impl Solution {
32    pub fn intersection(nums1: Vec<i32>, nums2: Vec<i32>) -> Vec<i32> {
33        vec![]
34    }
35}
36
37// submission codes end
38
39#[cfg(test)]
40mod tests {
41    use super::*;
42
43    #[test]
44    fn test_349() {
45    }
46}
47


Back
© 2025 bowen.ge All Rights Reserved.