2525. Categorize Box According to Criteria

Difficulty:
Related Topics:
Similar Questions:

Problem

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**.

The box is "Bulky" if:

Note that the volume of the box is the product of its length, width and height.

  Example 1:

Input: length = 1000, width = 35, height = 700, mass = 300
Output: "Heavy"
Explanation: 
None of the dimensions of the box is greater or equal to 104. 
Its volume = 24500000 <= 109. So it cannot be categorized as "Bulky".
However mass >= 100, so the box is "Heavy".
Since the box is not "Bulky" but "Heavy", we return "Heavy".

Example 2:

Input: length = 200, width = 50, height = 800, mass = 50
Output: "Neither"
Explanation: 
None of the dimensions of the box is greater or equal to 104.
Its volume = 8 * 106 <= 109. So it cannot be categorized as "Bulky".
Its mass is also less than 100, so it cannot be categorized as "Heavy" either. 
Since its neither of the two above categories, we return "Neither".

  Constraints:

Solution (Java)

class Solution {
    public String categorizeBox(int length, int width, int height, int mass) {
        if(isBulky(length,width,height) && mass >= 100)     return "Both";
        else if(!(isBulky(length,width,height)) && mass < 100)      return "Neither";
        else if(!(isBulky(length,width,height)) && mass >= 100)     return "Heavy";
        else    return "Bulky";

    }
    private static boolean isBulky(int length, int width, int height){
        long volume = (long)length * (long)width * (long)height;

        if(Math.max(length,Math.max(width,height)) >= 10_000)   return true;
        if( volume >= 1000_000_000) return true;
        return false;
    }
}

Explain:

nope.

Complexity: