LC 1189. Maximum Number of Balloons

Nilanjan Deb · April 5, 2020

This is my CPP solution.

class Solution {
public:
    int maxNumberOfBalloons(string text) {
        int b = count(text.begin(),text.end(),'b');
        int a = count(text.begin(),text.end(),'a');
        int l = count(text.begin(),text.end(),'l')/2;
        int o = count(text.begin(),text.end(),'o')/2;
        int n = count(text.begin(),text.end(),'n');
        return min(b,min(a,min(l,min(o,n))));
    }
};


Dicussion Forum