diff --git a/solution/2500-2599/2525.Categorize Box According to Criteria/README.md b/solution/2500-2599/2525.Categorize Box According to Criteria/README.md index 51f029716a3ad..7bf81c1052b85 100644 --- a/solution/2500-2599/2525.Categorize Box According to Criteria/README.md +++ b/solution/2500-2599/2525.Categorize Box According to Criteria/README.md @@ -84,6 +84,23 @@ class Solution: return d[i] ``` +```python +class Solution: + def categorizeBox(self, length: int, width: int, height: int, mass: int) -> str: + v = length * width * height + bulky = any(x >= 10000 for x in (length, width, height)) or v >= 10**9 + heavy = mass >= 100 + + if bulky and heavy: + return "Both" + if bulky: + return "Bulky" + if heavy: + return "Heavy" + + return "Neither" +``` + ### **Java** @@ -101,6 +118,28 @@ class Solution { } ``` +```java +class Solution { + public String categorizeBox(int length, int width, int height, int mass) { + long v = (long) length * width * height; + boolean bulky = length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9; + boolean heavy = mass >= 100; + + if (bulky && heavy) { + return "Both"; + } + if (bulky) { + return "Bulky"; + } + if (heavy) { + return "Heavy"; + } + + return "Neither"; + } +} +``` + ### **C++** ```cpp @@ -117,6 +156,29 @@ public: }; ``` +```cpp +class Solution { +public: + string categorizeBox(int length, int width, int height, int mass) { + long v = (long) length * width * height; + bool bulky = length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9; + bool heavy = mass >= 100; + + if (bulky && heavy) { + return "Both"; + } + if (bulky) { + return "Bulky"; + } + if (heavy) { + return "Heavy"; + } + + return "Neither"; + } +}; +``` + ### **Go** ```go @@ -134,6 +196,24 @@ func categorizeBox(length int, width int, height int, mass int) string { } ``` +```go +func categorizeBox(length int, width int, height int, mass int) string { + v := length * width * height + bulky := length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9 + heavy := mass >= 100 + if bulky && heavy { + return "Both" + } + if bulky { + return "Bulky" + } + if heavy { + return "Heavy" + } + return "Neither" +} +``` + ### **TypeScript** ```ts @@ -150,6 +230,24 @@ function categorizeBox(length: number, width: number, height: number, mass: numb } ``` +```ts +function categorizeBox(length: number, width: number, height: number, mass: number): string { + const v = length * width * height; + const bulky = length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9; + const heavy = mass >= 100; + if (bulky && heavy) { + return 'Both'; + } + if (bulky) { + return 'Bulky'; + } + if (heavy) { + return 'Heavy'; + } + return 'Neither'; +} +``` + ### **Rust** ```rust @@ -172,6 +270,29 @@ impl Solution { } ``` +```rust +impl Solution { + pub fn categorize_box(length: i32, width: i32, height: i32, mass: i32) -> String { + let v = length * width * height; + let bulky = length >= 10000 || width >= 10000 || height >= 10000 || length as i64 * width as i64 * height as i64 >= 1000000000; + + let heavy = mass >= 100; + + if bulky && heavy { + return "Both".to_string(); + } + if bulky { + return "Bulky".to_string(); + } + if heavy { + return "Heavy".to_string(); + } + + "Neither".to_string() + } +} +``` + ### **...** ``` diff --git a/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md b/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md index 62d90f7eb9ac1..3803a1000109c 100644 --- a/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md +++ b/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md @@ -55,6 +55,12 @@ Since its neither of the two above categories, we return "Neither".

### **Python3** @@ -70,6 +76,23 @@ class Solution: return d[i] ``` +```python +class Solution: + def categorizeBox(self, length: int, width: int, height: int, mass: int) -> str: + v = length * width * height + bulky = any(x >= 10000 for x in (length, width, height)) or v >= 10**9 + heavy = mass >= 100 + + if bulky and heavy: + return "Both" + if bulky: + return "Bulky" + if heavy: + return "Heavy" + + return "Neither" +``` + ### **Java** ```java @@ -85,6 +108,28 @@ class Solution { } ``` +```java +class Solution { + public String categorizeBox(int length, int width, int height, int mass) { + long v = (long) length * width * height; + boolean bulky = length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9; + boolean heavy = mass >= 100; + + if (bulky && heavy) { + return "Both"; + } + if (bulky) { + return "Bulky"; + } + if (heavy) { + return "Heavy"; + } + + return "Neither"; + } +} +``` + ### **C++** ```cpp @@ -101,6 +146,29 @@ public: }; ``` +```cpp +class Solution { +public: + string categorizeBox(int length, int width, int height, int mass) { + long v = (long) length * width * height; + bool bulky = length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9; + bool heavy = mass >= 100; + + if (bulky && heavy) { + return "Both"; + } + if (bulky) { + return "Bulky"; + } + if (heavy) { + return "Heavy"; + } + + return "Neither"; + } +}; +``` + ### **Go** ```go @@ -118,6 +186,24 @@ func categorizeBox(length int, width int, height int, mass int) string { } ``` +```go +func categorizeBox(length int, width int, height int, mass int) string { + v := length * width * height + bulky := length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9 + heavy := mass >= 100 + if bulky && heavy { + return "Both" + } + if bulky { + return "Bulky" + } + if heavy { + return "Heavy" + } + return "Neither" +} +``` + ### **TypeScript** ```ts @@ -134,6 +220,24 @@ function categorizeBox(length: number, width: number, height: number, mass: numb } ``` +```ts +function categorizeBox(length: number, width: number, height: number, mass: number): string { + const v = length * width * height; + const bulky = length >= 1e4 || width >= 1e4 || height >= 1e4 || v >= 1e9; + const heavy = mass >= 100; + if (bulky && heavy) { + return 'Both'; + } + if (bulky) { + return 'Bulky'; + } + if (heavy) { + return 'Heavy'; + } + return 'Neither'; +} +``` + ### **Rust** ```rust @@ -156,6 +260,29 @@ impl Solution { } ``` +```rust +impl Solution { + pub fn categorize_box(length: i32, width: i32, height: i32, mass: i32) -> String { + let v = length * width * height; + let bulky = length >= 10000 || width >= 10000 || height >= 10000 || length as i64 * width as i64 * height as i64 >= 1000000000; + + let heavy = mass >= 100; + + if bulky && heavy { + return "Both".to_string(); + } + if bulky { + return "Bulky".to_string(); + } + if heavy { + return "Heavy".to_string(); + } + + "Neither".to_string() + } +} +``` + ### **...** ```