• + 0 comments

    JavaScript

    function cutTheSticks(arr) {
        // Write your code here
        const result = [];
    
        while (arr.length > 0) {
        result.push(arr.length);
        const minLength = Math.min(...arr);
        arr = arr.map(stick => stick - minLength).filter(stick => stick > 0);
        }
    
      return result;
    
    }