3731. Find Missing Elements Easy
1/**
2 * [3731] Find Missing Elements
3 *
4 * You are given an integer array nums consisting of unique integers.
5 * Originally, nums contained every integer within a certain range. However, some integers might have gone missing from the array.
6 * The smallest and largest integers of the original range are still present in nums.
7 * Return a sorted list of all the missing integers in this range. If no integers are missing, return an empty list.
8 *
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">nums = [1,4,2,5]</span>
12 * Output: <span class="example-io">[3]</span>
13 * Explanation:
14 * The smallest integer is 1 and the largest is 5, so the full range should be [1,2,3,4,5]. Among these, only 3 is missing.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">nums = [7,8,6,9]</span>
19 * Output: <span class="example-io">[]</span>
20 * Explanation:
21 * The smallest integer is 6 and the largest is 9, so the full range is [6,7,8,9]. All integers are already present, so no integer is missing.
22 * </div>
23 * <strong class="example">Example 3:
24 * <div class="example-block">
25 * Input: <span class="example-io">nums = [5,1]</span>
26 * Output: <span class="example-io">[2,3,4]</span>
27 * Explanation:
28 * The smallest integer is 1 and the largest is 5, so the full range should be [1,2,3,4,5]. The missing integers are 2, 3, and 4.
29 * </div>
30 *
31 * Constraints:
32 *
33 * 2 <= nums.length <= 100
34 * 1 <= nums[i] <= 100
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/find-missing-elements/
40// discuss: https://leetcode.com/problems/find-missing-elements/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn find_missing_elements(nums: Vec<i32>) -> Vec<i32> {
46 vec![]
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_3731() {
58 }
59}
60Back
© 2026 bowen.ge All Rights Reserved.