C++ easy to understand solution
IntuitionWe need to build the lexicographically largest string with the repeatLimit number of occurences of a character at any time. The largest character shoul
# Intuition\nWe need to build the `lexicographically largest` string with the `repeatLimit` number of occurences of a character at any time. The largest character should come first. The trick is to keep the repetition of a particular character `rep` in `s` as `rep <= repeatLimit`\n\n# Approach\nWe store the occurences of all characters in  the string in a hashmap. The character repetitions can either be smaller, equal or greater than the `repeatLimit`, so we need to check that first. If the frequency `rep` is smaller or equal, we can easily construct our string. Otherwise we search an immediate smaller character `temp`, add it in the middle and continue. As the `answer` doesn\'t need to contain all the characters of the original string `s`, we can continue with the next character if we don\'t find an immediate smaller character.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string repeatLimitedString(string s, int repeatLimit) {\n        string ans = "";\n        map<char,int> mp;\n        for(char ch : s){\n            mp[ch]++;\n        }\n        for(char ch = \'z\'; ch >= \'a\'; ch--){\n            if(mp.find(ch) == mp.end()) continue;\n            int rep = mp[ch];\n            if(rep <= repeatLimit){\n                for(int i = 0; i < rep; i++){\n                    ans += ch;\n                }\n                mp.erase(ch);\n            }\n            else{\n                start:\n                for(int i = 0; i < min(rep,repeatLimit); i++){\n                    ans += ch;\n                }\n                rep -= repeatLimit;\n                if(rep > 0){\n                char temp = ch;\n                temp--;\n                while(temp >= \'a\'){\n                    if(mp.find(temp) != mp.end()){\n                        ans += temp;\n                        mp[temp]--;\n                        if(mp[temp] == 0)\n                            mp.erase(temp);\n                        goto start;\n                    }\n                    temp--;\n                }\n            }\n        }\n        }\n        return ans;\n    }\n};\n```
['Hash Table', 'String', 'Counting', 'Iterator', 'C++']