2525. Categorize Box According to Criteria Easy
1/**
2 * [2525] Categorize Box According to Criteria
3 *
4 * Given four integers length, width, height, and mass, representing the dimensions and mass of a box, respectively, return a string representing the category of the box.
5 *
6 * The box is "Bulky" if:
7 *
8 * Any of the dimensions of the box is greater or equal to 10^4.
9 * Or, the volume of the box is greater or equal to 10^9.
10 *
11 *
12 * If the mass of the box is greater or equal to 100, it is "Heavy".
13 * If the box is both "Bulky" and "Heavy", then its category is "Both".
14 * If the box is neither "Bulky" nor "Heavy", then its category is "Neither".
15 * If the box is "Bulky" but not "Heavy", then its category is "Bulky".
16 * If the box is "Heavy" but not "Bulky", then its category is "Heavy".
17 *
18 * Note that the volume of the box is the product of its length, width and height.
19 *
20 * <strong class="example">Example 1:
21 *
22 * Input: length = 1000, width = 35, height = 700, mass = 300
23 * Output: "Heavy"
24 * Explanation:
25 * None of the dimensions of the box is greater or equal to 10^4.
26 * Its volume = 24500000 <= 10^9. So it cannot be categorized as "Bulky".
27 * However mass >= 100, so the box is "Heavy".
28 * Since the box is not "Bulky" but "Heavy", we return "Heavy".
29 * <strong class="example">Example 2:
30 *
31 * Input: length = 200, width = 50, height = 800, mass = 50
32 * Output: "Neither"
33 * Explanation:
34 * None of the dimensions of the box is greater or equal to 10^4.
35 * Its volume = 8 * 10^6 <= 10^9. So it cannot be categorized as "Bulky".
36 * Its mass is also less than 100, so it cannot be categorized as "Heavy" either.
37 * Since its neither of the two above categories, we return "Neither".
38 *
39 * Constraints:
40 *
41 * 1 <= length, width, height <= 10^5
42 * 1 <= mass <= 10^3
43 *
44 */
45pub struct Solution {}
46
47// problem: https://leetcode.com/problems/categorize-box-according-to-criteria/
48// discuss: https://leetcode.com/problems/categorize-box-according-to-criteria/discuss/?currentPage=1&orderBy=most_votes&query=
49
50// submission codes start here
51
52impl Solution {
53 pub fn categorize_box(length: i32, width: i32, height: i32, mass: i32) -> String {
54 String::new()
55 }
56}
57
58// submission codes end
59
60#[cfg(test)]
61mod tests {
62 use super::*;
63
64 #[test]
65 fn test_2525() {
66 }
67}
68
Back
© 2025 bowen.ge All Rights Reserved.