Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int numberOfSubstrings(string s) {
- int ans=0, last[3] = {-1, -1, -1};
- for(int i=0; i<s.length(); i++){
- last[s[i]-'a'] = i;
- ans += 1+min({last[0], last[1], last[2]});
- }
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment