632. Smallest Range Covering Elements from K Lists Hard
1/**
2 * [632] Smallest Range Covering Elements from K Lists
3 *
4 * You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists.
5 * We define the range [a, b] is smaller than range [c, d] if b - a < d - c or a < c if b - a == d - c.
6 *
7 * Example 1:
8 *
9 * Input: nums = [[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]
10 * Output: [20,24]
11 * Explanation:
12 * List 1: [4, 10, 15, 24,26], 24 is in range [20,24].
13 * List 2: [0, 9, 12, 20], 20 is in range [20,24].
14 * List 3: [5, 18, 22, 30], 22 is in range [20,24].
15 *
16 * Example 2:
17 *
18 * Input: nums = [[1,2,3],[1,2,3],[1,2,3]]
19 * Output: [1,1]
20 *
21 *
22 * Constraints:
23 *
24 * nums.length == k
25 * 1 <= k <= 3500
26 * 1 <= nums[i].length <= 50
27 * -10^5 <= nums[i][j] <= 10^5
28 * nums[i] is sorted in non-decreasing order.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/
34// discuss: https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn smallest_range(nums: Vec<Vec<i32>>) -> Vec<i32> {
40 vec![]
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_632() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.