Skip to content

Commit 06916f0

Browse files
committed
2525. Categorize Box According to Criteria
1 parent 7869b6c commit 06916f0

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
3+
1. 아이디어 : 조건에 맞게 체크
4+
5+
2. 시간복잡도 : O(9)
6+
7+
3. 자료구조/알고리즘 : 조건문
8+
9+
*/
10+
11+
class Solution {
12+
public String categorizeBox(int length, int width, int height, int mass) {
13+
14+
int BULKY_VOLUME = 1000000000;
15+
int BULKY_LEN = 10000;
16+
int HEAVY = 100;
17+
18+
boolean isHeavy = false;
19+
boolean isBulky = false;
20+
21+
if(mass >= HEAVY) isHeavy = true;
22+
23+
if(length >= BULKY_LEN) isBulky = true;
24+
else if(width >= BULKY_LEN) isBulky = true;
25+
else if(height >= BULKY_LEN) isBulky = true;
26+
else if((long)width*height*length>=BULKY_VOLUME) isBulky = true;
27+
28+
if(isBulky && isHeavy) return "Both";
29+
else if(!isBulky && !isHeavy) return "Neither";
30+
31+
if(isBulky) return "Bulky";
32+
33+
return "Heavy";
34+
35+
}
36+
}

0 commit comments

Comments
 (0)