1class Solution {2public:3vector<int> partitionLabels(string s) {4unordered_map<char, int> mp;5// filling impact of character's6for (int i = 0; i < s.size(); i++) {7char ch = s[i];8mp[ch] = i;9}10// making of result11vector<int> res;12int prev = -1;13int maxi = 0;1415for (int i = 0; i < s.size(); i++) {16maxi = max(maxi, mp[s[i]]);17if (maxi == i) {18// partition time19res.push_back(maxi - prev);20prev = maxi;21}22}23return res;24}25};