Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 452 Bytes

File metadata and controls

18 lines (14 loc) · 452 Bytes

Screen Shot 2023-01-14 at 1 29 07 PM

/**
 * @param {string} text
 * @return {number}
 */
var maxNumberOfBalloons = function(text) {
    let obj = {b: 0, a: 0, l: 0, o: 0, n: 0};

    for(let n of text) {
        obj[n]++;
    }

    return Math.floor(Math.min(obj.b, obj.a, obj.l / 2, obj.o / 2, obj.n));
};