Count Substrings With K-Frequency Characters I || LeetCode Weekly Contest 420 || Leetcode Solution

preview_player
Показать описание
Count Substrings With K-Frequency Characters I || LeetCode Weekly Contest 420 || Leetcode Solution

leetcode weekly contest solutions today, leetcode contest solutions live, leetcode solutions, leetcode contest 420, leetcode weekly contest 420, coding, programming, competitive programming, coding tutorials, leetcode, leetcode editorials
Рекомендации по теме
Комментарии
Автор

class Solution {
public:
int numberOfSubstrings(string s, int k) {
int n = s.size();
int ans = 0;
for (int i = 0; i < n; i++) {
vector<int> freq(26, 0);
for (int j = i; j < n; j++) {
freq[s[j] - 'a']++;
if (any_of(freq.begin(), freq.end(), [&](int f){ return f >= k; })) {
ans++;
}
}
}
return ans;
}
};

neettarget
Автор

Bruh explain me this.. we have to write the algorithm

dhanushm