Skip to content

Commit b4865e6

Browse files
authored
Add categorizeBox function for box classification
Implement categorizeBox function to classify boxes based on dimensions and mass.
1 parent 2ace635 commit b4865e6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number} length
3+
* @param {number} width
4+
* @param {number} height
5+
* @param {number} mass
6+
* @return {string}
7+
*/
8+
9+
// 시간 복잡도 O(1)
10+
var categorizeBox = function(length, width, height, mass) {
11+
let volume = length * width * height;
12+
if ((volume >= 10**9 || length >= 10**4 || width >= 10**4 || height >= 10**4) && (mass>=100)){
13+
return "Both";
14+
} else if (mass >= 100){
15+
return "Heavy";
16+
} else if (volume >= 10**9 || length >= 10**4 || width >= 10**4 || height >= 10**4){
17+
return "Bulky";
18+
}
19+
else { return "Neither" };
20+
};

0 commit comments

Comments
 (0)