Package Sorter

Medium2s max execution

As a developer at an automated warehouse, you need to implement a smart package sorting system that categorizes packages based on their dimensions and weight.

📦 Package Categories:

BULKY Packages

A package is considered bulky if either:

  • 📏 Volume (width × height × length) is ≥ 1,000,000 cm³
  • 📐 Any single dimension is ≥ 150 cm

HEAVY Packages

A package is considered heavy if:

  • ⚖️ Mass is ≥ 20 kg

Sorting Categories

STANDARD Neither bulky nor heavy
SPECIAL Either bulky or heavy (but not both)
REJECTED Both bulky and heavy

💡 Quick Example:

For a package with dimensions 100×100×100 cm and mass 15 kg:

  • Volume = 1,000,000 cm³ (at bulky threshold)
  • No dimension ≥ 150 cm
  • Mass < 20 kg (not heavy)
  • Result: "SPECIAL" (bulky but not heavy)

🎯 Your Task:

Implement the sort method in the PackageSorter class that takes:

  • width (cm)
  • height (cm)
  • length (cm)
  • mass (kg)

And returns the appropriate category as a string: "STANDARD", "SPECIAL", or "REJECTED".

Examples:

Input: [50, 50, 50, 15]
Output: "STANDARD"

Volume: 125,000 cm³ (not bulky), Mass: 15 kg (not heavy) → STANDARD

Input: [100, 100, 100, 15]
Output: "SPECIAL"

Volume: 1,000,000 cm³ (bulky), Mass: 15 kg (not heavy) → SPECIAL

Input: [50, 50, 150, 15]
Output: "SPECIAL"

One dimension ≥ 150 cm (bulky), Mass: 15 kg (not heavy) → SPECIAL

Input: [50, 50, 50, 20]
Output: "SPECIAL"

Volume: 125,000 cm³ (not bulky), Mass: 20 kg (heavy) → SPECIAL

Input: [150, 150, 150, 20]
Output: "REJECTED"

Dimensions ≥ 150 cm (bulky) AND Mass: 20 kg (heavy) → REJECTED

Constraints:

  • 1 ≤ width, height, length ≤ 300 (all in centimeters)
  • 1 ≤ mass ≤ 100 (in kilograms)
  • All inputs are integers
  • Function must return exactly 'STANDARD', 'SPECIAL', or 'REJECTED'
TypeScript solution with full type checking
Loading...

Custom Test Input

Output

Run your code to see output...