|
| 1 | +/** |
| 2 | + * [2274] Maximum Consecutive Floors Without Special Floors |
| 3 | + * |
| 4 | + * Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only. |
| 5 | + * You are given two integers bottom and top, which denote that Alice has rented all the floors from bottom to top (inclusive). You are also given the integer array special, where special[i] denotes a special floor that Alice has designated for relaxation. |
| 6 | + * Return the maximum number of consecutive floors without a special floor. |
| 7 | + * |
| 8 | + * Example 1: |
| 9 | + * |
| 10 | + * Input: bottom = 2, top = 9, special = [4,6] |
| 11 | + * Output: 3 |
| 12 | + * Explanation: The following are the ranges (inclusive) of consecutive floors without a special floor: |
| 13 | + * - (2, 3) with a total amount of 2 floors. |
| 14 | + * - (5, 5) with a total amount of 1 floor. |
| 15 | + * - (7, 9) with a total amount of 3 floors. |
| 16 | + * Therefore, we return the maximum number which is 3 floors. |
| 17 | + * |
| 18 | + * Example 2: |
| 19 | + * |
| 20 | + * Input: bottom = 6, top = 8, special = [7,6,8] |
| 21 | + * Output: 0 |
| 22 | + * Explanation: Every floor rented is a special floor, so we return 0. |
| 23 | + * |
| 24 | + * |
| 25 | + * Constraints: |
| 26 | + * |
| 27 | + * 1 <= special.length <= 10^5 |
| 28 | + * 1 <= bottom <= special[i] <= top <= 10^9 |
| 29 | + * All the values of special are unique. |
| 30 | + * |
| 31 | + */ |
| 32 | +pub struct Solution {} |
| 33 | + |
| 34 | +// problem: https://leetcode.com/problems/maximum-consecutive-floors-without-special-floors/ |
| 35 | +// discuss: https://leetcode.com/problems/maximum-consecutive-floors-without-special-floors/discuss/?currentPage=1&orderBy=most_votes&query= |
| 36 | + |
| 37 | +// submission codes start here |
| 38 | + |
| 39 | +impl Solution { |
| 40 | + pub fn max_consecutive(bottom: i32, top: i32, special: Vec<i32>) -> i32 { |
| 41 | + 0 |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +// submission codes end |
| 46 | + |
| 47 | +#[cfg(test)] |
| 48 | +mod tests { |
| 49 | + use super::*; |
| 50 | + |
| 51 | + #[test] |
| 52 | + #[ignore] |
| 53 | + fn test_2274_example_1() { |
| 54 | + let bottom = 2; |
| 55 | + let top = 9; |
| 56 | + let special = vec![4, 6]; |
| 57 | + |
| 58 | + let result = 3; |
| 59 | + |
| 60 | + assert_eq!(Solution::max_consecutive(bottom, top, special), result); |
| 61 | + } |
| 62 | + |
| 63 | + #[test] |
| 64 | + #[ignore] |
| 65 | + fn test_2274_example_2() { |
| 66 | + let bottom = 6; |
| 67 | + let top = 8; |
| 68 | + let special = vec![7, 6, 8]; |
| 69 | + |
| 70 | + let result = 0; |
| 71 | + |
| 72 | + assert_eq!(Solution::max_consecutive(bottom, top, special), result); |
| 73 | + } |
| 74 | +} |
0 commit comments