question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
maximum-number-of-non-overlapping-palindrome-substrings | Look at this --You won't find it hard..(Dp+Memoization -C++ code) | look-at-this-you-wont-find-it-harddpmemo-dew6 | Intuition\n Describe your first thoughts on how to solve this problem. \nFist of all i would say it doesn\'t have much beats but its alright,as my approach is s | manmeet_muskan | NORMAL | 2023-10-27T10:16:38.134424+00:00 | 2023-10-27T10:16:38.134448+00:00 | 30 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFist of all i would say it doesn\'t have much beats but its alright,as my approach is something that will be naturally clicking for everybody who knows even abc of dynamic programming (i.e. inclusion or exclusion).\nIt is simply if i am c... | 1 | 0 | ['Dynamic Programming', 'Recursion', 'Memoization', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Java || Easy Solution || With Explanation || Better than 100% | java-easy-solution-with-explanation-bett-30qm | Intuition\nGreedy Algorithm\n\n# Approach\n1. Firstly, check for k length palindrome \n2. If K length is not found then go for k+1 length palindrome. \nWe only | chhavigupta095 | NORMAL | 2023-10-12T03:01:20.612557+00:00 | 2023-10-12T03:01:20.612574+00:00 | 30 | false | # Intuition\nGreedy Algorithm\n\n# Approach\n1. Firstly, check for k length palindrome \n2. If K length is not found then go for k+1 length palindrome. \nWe only have to check for even length and odd length palindrome and keep increasing count.\n\n\n# Complexity\n- Time complexity:\nO(N*k)\n\n- Space complexity:\nO(1)\... | 1 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Recursion + Memoization (1D DP) | recursion-memoization-1d-dp-by-diwaakar8-igj0 | Complexity\n- Time complexity:\n O (n * k)\n\n- Space complexity:\n O (n)\n\n# Code\n\nclass Solution {\npublic:\n int f (int i, int j, int &k, string | Diwaakar84 | NORMAL | 2023-08-08T13:50:52.997430+00:00 | 2023-08-08T13:57:15.905586+00:00 | 299 | false | # Complexity\n- Time complexity:\n O (n * k)\n\n- Space complexity:\n O (n)\n\n# Code\n```\nclass Solution {\npublic:\n int f (int i, int j, int &k, string &s, vector <bool> &dp)\n {\n if (i < 0 || j >= s.size ())\n return 0; //Out of bounds base case\n\n if (s [i] != s [j] || dp... | 1 | 0 | ['String', 'Dynamic Programming', 'Greedy', 'Recursion', 'Memoization', 'C++'] | 1 |
maximum-number-of-non-overlapping-palindrome-substrings | Simple Python Solution O(n) with explanation 🔥 | simple-python-solution-on-with-explanati-pgtz | Approach\n\n\n\n\nPalindromic substring cannot overlap, this means\n\nmax_count(0, i) = max_count(0, j) + max_count(j, i)\n\nwhere 0 <= j <= i\n\nNow, \n\n we h | wilspi | NORMAL | 2023-01-22T16:30:02.992961+00:00 | 2023-01-22T18:03:44.170882+00:00 | 158 | false | # Approach\n\n\n\n\nPalindromic substring cannot overlap, this means\n\n`max_count(0, i) = max_count(0, j) + max_count(j, i)`\n\nwhere `0 <= j <= i`\n\nNow, \n\n* we have to maximise ... | 1 | 0 | ['String', 'Dynamic Programming', 'Python', 'Python3'] | 1 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ Easy Solution | Two Pointer | Runtime 0 ms Beats 100% | c-easy-solution-two-pointer-runtime-0-ms-xbn5 | Intuition\nGiven string contains a palindrome substring or not.\nLongest Palindromic Substring - Try to solve this question with two pointer approach.\n\n# Appr | abhinandan__22 | NORMAL | 2022-12-29T18:22:11.398951+00:00 | 2022-12-29T18:24:53.199692+00:00 | 217 | false | # Intuition\nGiven string contains a palindrome substring or not.\n[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/description/) - Try to solve this question with two pointer approach.\n\n# Approach\nTraverse a string for every character of the string, inzilate two pointers (... | 1 | 0 | ['Two Pointers', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Breaking problem into sub problems and taking only k & k+1 length palindromic substrings | breaking-problem-into-sub-problems-and-t-cuh3 | If we break down the problems into sub problems we can easily solve it\nFirst find all the palindromic substrings using gap strategy and while doing that keep t | mayur_madhwani | NORMAL | 2022-11-15T01:24:23.285202+00:00 | 2022-11-15T01:24:23.285245+00:00 | 298 | false | If we break down the problems into sub problems we can easily solve it\nFirst find all the palindromic substrings using gap strategy and while doing that keep the start and end indices of all the substrings that have length k and k+1\nWhy k and k+1, because the substrings with length k+2 will have strings of length k i... | 1 | 0 | ['C++'] | 1 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ ✅✅| Greedy Approach 🔥| Easy and Simplified | 2 Approach | | c-greedy-approach-easy-and-simplified-2-hsgld | \n# Solution 1\n\nclass Solution {\npublic:\n bool ispal(string s,int l,int r){\n while(l<r){\n if(s[l]!=s[r]){\n return fal | kunal0612 | NORMAL | 2022-11-13T15:15:10.489202+00:00 | 2022-11-13T15:15:10.489235+00:00 | 285 | false | \n# Solution 1\n```\nclass Solution {\npublic:\n bool ispal(string s,int l,int r){\n while(l<r){\n if(s[l]!=s[r]){\n return false;\n }\n l++;\n r--;\n }\n return true;\n }\n int maxPalindromes(string s, int k) {\n int n=s.si... | 1 | 0 | ['C++'] | 1 |
maximum-number-of-non-overlapping-palindrome-substrings | [Python3] cutting short is always better than cutting long | python3-cutting-short-is-always-better-t-zmsr | If the minimum cutting length k==3, then we always find palindrome of length 3 or 4, even if the actual palindrome is much longer. Because long or short, each p | yuanzhi247012 | NORMAL | 2022-11-13T14:42:39.607242+00:00 | 2022-11-14T03:22:28.217643+00:00 | 301 | false | If the minimum cutting length k==3, then we always find palindrome of length 3 or 4, even if the actual palindrome is much longer. Because long or short, each palindrome can only contribute +1 to the result, and short palindrome can offer more possibilities for the rest parts.\n\n**dp(i)** means the max number of valid... | 1 | 0 | [] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | True O(n) - DP + Manacher | true-on-dp-manacher-by-durvorezbariq-pd54 | We use Manacher to check if a substring is a palindrome in O(1)\n- Manacher(s) preprocessing is O(n)\n- palin(i,i+k) checks if s[i:i+k] is palindrome in O(1)\n- | durvorezbariq | NORMAL | 2022-11-13T14:23:10.791816+00:00 | 2022-12-06T11:33:02.584263+00:00 | 39 | false | We use Manacher to check if a substring is a palindrome in O(1)\n- `Manacher(s)` preprocessing is O(n)\n- `palin(i,i+k)` checks if `s[i:i+k]` is palindrome in O(1)\n- `dp` is `O(n)`\n\n```\nclass Solution:\n def maxPalindromes(self, s: str, k: int) -> int:\n def Manacher(s):\n T = \'$#\'+\'#\'.join... | 1 | 0 | ['Dynamic Programming'] | 2 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ || Simple O(n) solution || Manacher's Algorithm | c-simple-on-solution-manachers-algorithm-l2lc | Pre-requisite: Learn about Manacher\'s algorithm\n\nclass Solution {\npublic:\n vector<int> manachers(string s){\n string str = "#";\n for(char | _Potter_ | NORMAL | 2022-11-13T05:41:21.566129+00:00 | 2022-11-13T05:42:06.365168+00:00 | 573 | false | **Pre-requisite:** Learn about [Manacher\'s algorithm](https://cp-algorithms.com/string/manacher.html/)\n```\nclass Solution {\npublic:\n vector<int> manachers(string s){\n string str = "#";\n for(char ch: s){\n str += ch;\n str += "#";\n }\n int c = 0, r = 0;\n ... | 1 | 0 | ['C', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Map + DP + Comments + Explanation! | map-dp-comments-explanation-by-whynesspo-81zj | Read the maxPalindromes function first.\n \nsolve function-> returns max number of non overlapping palindrome strings up to index currentIndx\n\n# Code\n\nclass | whynesspower | NORMAL | 2022-11-13T05:11:17.606410+00:00 | 2022-11-13T05:11:17.606453+00:00 | 303 | false | Read the maxPalindromes function first.\n \nsolve function-> returns max number of non overlapping palindrome strings up to index currentIndx\n\n# Code\n```\nclass Solution {\npublic:\n \n vector<int>dp;\n //dp[i] stores the max number of non overlapping palindrome strings upto index i \n map<int,int>Start... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ | DP | c-dp-by-coz_its_raunak-boqs | \n\nclass Solution {\npublic:\n \n int recc(vector<vector<int>>& adj, int i , int k, vector<int>& dpp)\n {\n if(i>=adj.size())\n retur | coz_its_raunak | NORMAL | 2022-11-13T04:52:04.913501+00:00 | 2022-11-13T04:52:04.913534+00:00 | 214 | false | ```\n\nclass Solution {\npublic:\n \n int recc(vector<vector<int>>& adj, int i , int k, vector<int>& dpp)\n {\n if(i>=adj.size())\n return 0;\n \n if(dpp[i]!=-1)\n {\n return dpp[i];\n }\n int ans = 0;\n for(int j = i+k-1;j<adj.size();j++)\... | 1 | 0 | ['Dynamic Programming'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Precalculate palindromic substrings and then solve independent intervals | precalculate-palindromic-substrings-and-ypqge | Intuition\n Describe your first thoughts on how to solve this problem. \n We already know a standard way to precalculate which substrings are palindromes in O(N | saikat93ify | NORMAL | 2022-11-13T04:48:48.086869+00:00 | 2022-11-13T04:48:48.086906+00:00 | 167 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* We already know a standard way to precalculate which substrings are palindromes in $$O(N^2)$$ time. \n* Notice that intervals are independent of each other\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n* Let $$... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ simple non-DP solution, 0ms beats 100% | c-simple-non-dp-solution-0ms-beats-100-b-cxud | https://leetcode.com/submissions/detail/842418022/\nRuntime: 0 ms\nTime complexity: O(k\xB7n)\nSpace complexity: O(1)\n\nclass Solution {\npublic:\n int maxP | netvope | NORMAL | 2022-11-13T04:34:37.641731+00:00 | 2022-11-13T04:43:25.721624+00:00 | 222 | false | https://leetcode.com/submissions/detail/842418022/\nRuntime: 0 ms\nTime complexity: O(k\xB7n)\nSpace complexity: O(1)\n```\nclass Solution {\npublic:\n int maxPalindromes(string s, int k) {\n const int n = s.size();\n int count = 0;\n int len = 0; // the shortest prefix length having _count_ sub... | 1 | 0 | ['Greedy', 'C'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | [Java] Rolling Hash + Dynamic Programming | java-rolling-hash-dynamic-programming-by-povp | \nclass Solution {\n private int[] record;\n private final int p = 31, mod1 = (int) (1e9 + 7);\n private int[] dp;\n public int maxPalindromes(Strin | nepo_ian | NORMAL | 2022-11-13T04:11:40.273485+00:00 | 2022-11-13T04:11:40.273520+00:00 | 105 | false | ```\nclass Solution {\n private int[] record;\n private final int p = 31, mod1 = (int) (1e9 + 7);\n private int[] dp;\n public int maxPalindromes(String s, int k) {\n\n int n = s.length();\n record = new int[n];\n Arrays.fill(record, -1);\n util(s, n, k);\n\n dp = new int[... | 1 | 0 | ['Dynamic Programming', 'Rolling Hash', 'Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | simple linear dp (0(n2)) | simple-linear-dp-0n2-by-aniketkumar1601-poqs | class Solution {\npublic:\n int maxPalindromes(string str, int k) {\n \n int n = str.length();\n \n int dp[n];\n \n | aniketkumar1601 | NORMAL | 2022-11-13T04:09:36.993668+00:00 | 2022-11-13T04:09:36.993695+00:00 | 197 | false | class Solution {\npublic:\n int maxPalindromes(string str, int k) {\n \n int n = str.length();\n \n int dp[n];\n \n for(int i = 0; i < n; i++)\n {\n dp[i] = 0;\n }\n \n for(int i = n-k; i >= 0 ; i--)\n {\n ... | 1 | 0 | ['C++'] | 1 |
maximum-number-of-non-overlapping-palindrome-substrings | Short C++ prefix xor solution | short-c-prefix-xor-solution-by-govind_pa-g9yt | \nclass Solution {\npublic:\n bool is_palin(int i, int j, string& s){\n while(i <= j){\n if(s[i] != s[j])\n return false; | govind_pandey | NORMAL | 2022-11-13T04:05:06.265387+00:00 | 2022-11-13T04:05:06.265422+00:00 | 51 | false | ```\nclass Solution {\npublic:\n bool is_palin(int i, int j, string& s){\n while(i <= j){\n if(s[i] != s[j])\n return false;\n i++;\n j--;\n }\n return true;\n \n }\n int maxPalindromes(string s, int k) {\n int temp = 0,ans ... | 1 | 0 | [] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | easy short efficient clean code | easy-short-efficient-clean-code-by-maver-olgn | \nclass Solution {\ntypedef long long ll;\n#define vi(x) vector<x>\npublic:\nll n, k;\nstring s;\nvi(vi(ll))dp, memo;\nbool palin(ll l, ll r){\n if(l>=r){\n | maverick09 | NORMAL | 2022-11-13T04:04:04.428324+00:00 | 2022-11-13T04:04:04.428368+00:00 | 220 | false | ```\nclass Solution {\ntypedef long long ll;\n#define vi(x) vector<x>\npublic:\nll n, k;\nstring s;\nvi(vi(ll))dp, memo;\nbool palin(ll l, ll r){\n if(l>=r){\n return 1;\n }\n ll&ans=memo[l][r];\n if(ans==-1){\n ans=palin(l+1, r-1) && s[l]==s[r];\n }\n return ans;\n}\nll func(ll in, ll p... | 1 | 0 | ['Dynamic Programming', 'Recursion', 'C'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | [c++] DP + sorting + greedy | c-dp-sorting-greedy-by-mble6125-cury | Approach\nstep 1. determin the substring s[i : j] is palindrome or not for all 0<=i, j< n.\nstep 2. record start point and end point of all palindrome substring | mble6125 | NORMAL | 2022-11-13T04:00:57.541577+00:00 | 2022-11-13T04:05:43.991989+00:00 | 258 | false | # Approach\nstep 1. determin the substring s[i : j] is palindrome or not for all 0<=i, j< n.\nstep 2. record start point and end point of all palindrome substring whose size greater or eqaul to k. \nstep 3. sort it by the end points in increasing order.\nstep 4. traverse all intervals. Greedily pick current interval if... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Top-Bottom DP explained | top-bottom-dp-explained-by-remedydev-mqej | ApproachTop-Down Dynamic Programming approach
We try to form a palindrome starting from every "i-th" index.
If we succeed, we call a recursion again to attempt | remedydev | NORMAL | 2025-03-25T17:46:22.039582+00:00 | 2025-03-25T17:46:22.039582+00:00 | 3 | false | # Approach
Top-Down Dynamic Programming approach
1. We try to form a palindrome starting from every "i-th" index.
2. If we succeed, we call a recursion again to attempt to form the next palindrome right after the current one.
3. We also try to skip the "start" index and attempt to form a larger answer starting from the... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | scala dp | scala-dp-by-vititov-p7lp | null | vititov | NORMAL | 2025-02-15T19:15:29.116061+00:00 | 2025-02-15T19:15:29.116061+00:00 | 2 | false | ```scala []
object Solution {
def maxPalindromes(s: String, k: Int): Int = {
val dp=Array.fill(s.length+1)(0)
@annotation.tailrec def check(i: Int, j:Int): Boolean =
(i>=j) || (s(i) == s(j) && check(i+1, j-1))
;var mx = 0; var i=0; while(i<s.length) {
;var j=i+k-1; while(j<s.length) {
... | 0 | 0 | ['Dynamic Programming', 'Scala'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | VERY simple recursive solution: $$O(n × k)$$ | very-simple-recursive-solution-on-x-k-by-g0ea | IntuitionWe always prefer to take the shortest palindrome available, leaving more characters available to be in other palindromes. A greedy approach will work.W | adam-hoelscher | NORMAL | 2025-02-07T23:47:14.272509+00:00 | 2025-02-07T23:47:14.272509+00:00 | 5 | false | # Intuition
We always prefer to take the shortest palindrome available, leaving more characters available to be in other palindromes. A greedy approach will work.
We can organize our search by checking for palindromes at the beginning of the string.
# Approach
For each character in the string, check to see if it is t... | 0 | 0 | ['Go'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Java | easy to understand | beats 100% | java-easy-to-understand-beats-100-by-dea-9soa | Understanding the Problem:Given a string s and an integer k, the goal is to find the maximum number of non-overlapping palindromic substrings in s, where each s | deadvikash | NORMAL | 2025-01-24T12:41:49.248931+00:00 | 2025-01-24T12:41:49.248931+00:00 | 6 | false |
Understanding the Problem:
Given a string s and an integer k, the goal is to find the maximum number of non-overlapping palindromic substrings in s, where each substring has a length of at least k.
Solution Approach:
The solution uses an approach that expands around centers. It checks for both odd-length and even-l... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | 2472. Maximum Number of Non-overlapping Palindrome Substrings | 2472-maximum-number-of-non-overlapping-p-paz8 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | G8xd0QPqTy | NORMAL | 2025-01-18T16:34:52.134144+00:00 | 2025-01-18T16:34:52.134144+00:00 | 7 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Maximum Number of Non-Overlapping Palindrome Substrings | maximum-number-of-non-overlapping-palind-32z4 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Naeem_ABD | NORMAL | 2024-12-23T18:48:30.020366+00:00 | 2024-12-23T18:48:30.020366+00:00 | 4 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['JavaScript'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Use greedy, no need for DP | use-greedy-no-need-for-dp-by-dharmenders-p9t8 | Code | dharmendersheshma | NORMAL | 2024-12-23T16:15:58.993215+00:00 | 2024-12-23T16:15:58.993215+00:00 | 4 | false | # Code
```java []
class Solution {
int ans;
public int maxPalindromes(String s, int k) {
ans = 0;
int i = 0;
int n = s.length();
int left = 0;
while(i < n) {
int right = getRightSideOfPal(left, s, i, k);
if(right == -1) {
i++;
... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | ✅DP || Python | dp-python-by-darkenigma-9ijg | Code | darkenigma | NORMAL | 2024-12-13T05:29:49.203111+00:00 | 2024-12-13T05:29:49.203111+00:00 | 7 | false | \n# Code\n```python3 []\nclass Solution:\n\n def check(self, i, k, n, dp2, dp):\n """\n Recursive function to find the maximum number of palindromic substrings \n of length at least k that can be extracted starting from index `i`.\n """\n # Base case: If we reach the end of the str... | 0 | 0 | ['Two Pointers', 'String', 'Dynamic Programming', 'Greedy', 'Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | 100% | 100-by-mythsky-bj63 | Uhh.. not sure if this should be medium. \nThe key is: the length of palindromes can be either odd or even. If the shorter case is already fit, then we don\'t n | mythsky | NORMAL | 2024-10-20T01:57:57.543685+00:00 | 2024-10-20T02:03:12.227049+00:00 | 4 | false | Uhh.. not sure if this should be medium. \nThe key is: the length of palindromes can be either odd or even. If the shorter case is already fit, then we don\'t need to check for the longer one(save the letters for the next check).\n\nNote: \nthe minimum length have to be k, k can be either odd or even\nodd+1=even\neven+... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Easy Iterative Dp Solution | easy-iterative-dp-solution-by-kvivekcode-m205 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | kvivekcodes | NORMAL | 2024-10-10T07:44:34.705023+00:00 | 2024-10-10T07:44:34.705068+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Dynamic Programming', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | [C++] GENERATE OPTIMAL INTERVALS | INTUITIVE SOLUTION | c-generate-optimal-intervals-intuitive-s-u4c4 | Complexity\n- Time complexity:\nO(n*n)\n\n- Space complexity:\nO(n)\n\n# Code\ncpp []\nclass Solution {\npublic:\n bool is_pal(string& s) {\n for (int | ahbar | NORMAL | 2024-09-24T06:02:18.244954+00:00 | 2024-09-24T06:02:18.244999+00:00 | 4 | false | # Complexity\n- Time complexity:\nO(n*n)\n\n- Space complexity:\nO(n)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n bool is_pal(string& s) {\n for (int i =0; i < s.size() / 2; i++) {\n if (s[i] != s[s.size() -1- i]) return false;\n }\n return true;\n }\n\n int maxPalindromes... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | eazy "o(n)" solution , Beats 60.00% | eazy-on-solution-beats-6000-by-ed_snowde-extg | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Ed_SNOWDEN_Eliot | NORMAL | 2024-09-17T12:45:08.352397+00:00 | 2024-09-17T12:45:08.352432+00:00 | 5 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: o(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```csharp []\npublic class Solution {\n public int MaxPali... | 0 | 0 | ['Two Pointers', 'String', 'Dynamic Programming', 'Greedy', 'C#'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | DP Solution. | dp-solution-by-arif2321-zqak | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Arif2321 | NORMAL | 2024-08-25T07:29:24.614641+00:00 | 2024-08-25T07:29:24.614672+00:00 | 3 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Best Answer without any knowledge of Dp simple approach easy no space | best-answer-without-any-knowledge-of-dp-jr4e4 | Intuition\nThe intuition behind the approach is based on the fact that if a larger palindrome (longer than k+1) exists, then smaller palindromic substrings with | MadhavGarg | NORMAL | 2024-08-17T23:09:16.021022+00:00 | 2024-08-17T23:14:35.335503+00:00 | 4 | false | # Intuition\nThe intuition behind the approach is based on the fact that if a larger palindrome (longer than `k+1`) exists, then smaller palindromic substrings within it can be found by incrementally checking lengths `k` and `k+1`.\n\n### Example\nLet\'s consider the string `s = "abaxyzyxba"` and let `k = 4`.\n\n1. **C... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | is it easy to understand this way !!! | is-it-easy-to-understand-this-way-by-san-x9bt | Intuition\n Describe your first thoughts on how to solve this problem. \n \n# Approach\n Describe your approach to solving the problem. \n - we go for every | sanchari0_1 | NORMAL | 2024-08-02T05:25:22.538392+00:00 | 2024-08-02T05:25:22.538418+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n \n# Approach\n<!-- Describe your approach to solving the problem. -->\n - we go for every index and check whether there is a palindrome starting with idx and has minimum length k . \n - we need to make sure the palindrome we are choo... | 0 | 0 | ['Dynamic Programming', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ DP O(n^2) | c-dp-on2-by-airusian2-60zh | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | AirusIan2 | NORMAL | 2024-07-30T02:23:51.245412+00:00 | 2024-07-30T02:23:51.245443+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ With Palindrome Length Array | c-with-palindrome-length-array-by-__amri-dlan | Intuition\nFirst we create a palindromeLength Array starting at each index i. And use this array to find disjoint subarrays of length = palindromeLength[i]\n\n# | __amrit__saha__ | NORMAL | 2024-07-22T13:32:39.873717+00:00 | 2024-07-22T13:32:39.873747+00:00 | 1 | false | # Intuition\nFirst we create a palindromeLength Array starting at each index i. And use this array to find disjoint subarrays of length = palindromeLength[i]\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n`... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Greedy dp | greedy-dp-by-fustigate-0gfa | Intuition\nsince substrings cannot overlap and we want as many palindromes as possible, it\'s best to only find palindromes with length of k or k + 1 (to accoun | Fustigate | NORMAL | 2024-07-18T03:59:08.522193+00:00 | 2024-07-18T03:59:08.522225+00:00 | 11 | false | # Intuition\nsince substrings cannot overlap and we want as many palindromes as possible, it\'s best to only find palindromes with length of k or k + 1 (to account for both even and odd length palindromes).\n\n# Code\n```python\nclass Solution:\n def maxPalindromes(self, s: str, k: int) -> int:\n def pal(i, j... | 0 | 0 | ['Dynamic Programming', 'Greedy', 'Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Python (Simple DP) | python-simple-dp-by-rnotappl-yrut | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | rnotappl | NORMAL | 2024-07-16T12:27:26.255026+00:00 | 2024-07-16T12:27:26.255053+00:00 | 3 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | ap | ap-by-ap5123-lfff | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ap5123 | NORMAL | 2024-07-08T19:41:59.523270+00:00 | 2024-07-08T19:41:59.523303+00:00 | 0 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Simple c++ | simple-c-by-khurkhur-9sk6 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | khurkhur | NORMAL | 2024-06-04T23:12:22.521641+00:00 | 2024-06-04T23:12:22.521663+00:00 | 2 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | [Python3] O(n) solution | python3-on-solution-by-coder-256-o1yl | Intuition\n Describe your first thoughts on how to solve this problem. \nUse Manacher\'s algorithm to calculate the max palindrome size centered at each letter | coder-256 | NORMAL | 2024-06-01T05:23:05.425381+00:00 | 2024-06-01T05:31:46.654083+00:00 | 11 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse Manacher\'s algorithm to calculate the max palindrome size centered at each letter (odd-length palindromes) and centered between two letters (even-length palindromes). To make this easier, we convert e.g. "abc" to "|a|b|c|", and store... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Similar to Palindrome Partitioning II | similar-to-palindrome-partitioning-ii-by-59yy | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | sumitpal1234 | NORMAL | 2024-05-31T21:13:05.232466+00:00 | 2024-05-31T21:13:05.232492+00:00 | 1 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Python || Clean and Easy Dynamic Programming Solution | python-clean-and-easy-dynamic-programmin-a4hx | python\nfrom functools import cache\n\n\nclass Solution:\n def maxPalindromes(self, s: str, k: int) -> int:\n n = len(s)\n dp = self.palindrome | shivkj | NORMAL | 2024-05-22T12:08:30.170106+00:00 | 2024-05-22T12:08:30.170135+00:00 | 11 | false | ```python\nfrom functools import cache\n\n\nclass Solution:\n def maxPalindromes(self, s: str, k: int) -> int:\n n = len(s)\n dp = self.palindrome_dp(s)\n\n @cache\n def max_palindromes(i: int) -> int:\n # finding idx such that s[i: idx + 1] is a palindrome\n idx = n... | 0 | 0 | ['Dynamic Programming', 'Memoization', 'Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | C++ || TOO EASY || CLEAN SHORT CODE || DP | c-too-easy-clean-short-code-dp-by-gaurav-w9kq | \n\n# Code\n\nclass Solution {\npublic:\n bool c(int i,int j,string &s)\n {\n while(i<j)\n if(s[i++]!=s[j--]) return 0;\n \n return 1;\ | Gauravgeekp | NORMAL | 2024-05-04T09:33:55.332669+00:00 | 2024-05-04T09:33:55.332692+00:00 | 2 | false | \n\n# Code\n```\nclass Solution {\npublic:\n bool c(int i,int j,string &s)\n {\n while(i<j)\n if(s[i++]!=s[j--]) return 0;\n \n return 1;\n }\n int t(int i,int n,string &s,vector<int> &dp,int k)\n {\n if(i>=n) return 0;\n if(dp[i]!=-1) return dp[i];\n\n int p=0,np=... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | DP solution in Go | dp-solution-in-go-by-mesge-izfm | Intuition\n1. Find all the valid palindromes i.e. any palindromic sequence that is at least as long as k\n2. Expressed as intervals along a line we can greedily | mesge | NORMAL | 2024-04-29T06:32:11.013205+00:00 | 2024-04-29T06:32:11.013244+00:00 | 9 | false | # Intuition\n1. Find all the valid palindromes i.e. any palindromic sequence that is at least as long as k\n2. Expressed as intervals along a line we can greedily find those that do not overlap. Greedy algorithm means we optimise space along the line to allow room for more palindromes.\n3. Count them\n\n# Approach\nUse... | 0 | 0 | ['Go'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Dynamic programming + Rolling Hash | dynamic-programming-rolling-hash-by-kaic-wpy5 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | kaicool9789 | NORMAL | 2024-03-15T09:00:04.711070+00:00 | 2024-03-15T09:00:04.711093+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Dynamic Programming', 'Rolling Hash', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | java dp | java-dp-by-mot882000-okgg | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | mot882000 | NORMAL | 2024-02-12T12:04:53.032886+00:00 | 2024-02-12T12:04:53.032910+00:00 | 12 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Dynamic Programming', 'Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | DP + greedy | dp-greedy-by-nuenuehao2-a593 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | nuenuehao2 | NORMAL | 2024-02-11T23:15:12.577117+00:00 | 2024-02-11T23:15:12.577136+00:00 | 7 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n^2)\n<!-- Add your space complexity here, e.... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Simple C++ | simple-c-by-zerojude-v7uz | \n\n# Code\n\n#include <bits/stdc++.h>\nusing namespace std ;\n\n#define ar array< int , 2 >\n\nclass Solution {\n\n int go( vector< ar > &A )\n {\n | zerojude | NORMAL | 2024-02-11T19:48:55.557555+00:00 | 2024-02-11T19:48:55.557584+00:00 | 5 | false | \n\n# Code\n```\n#include <bits/stdc++.h>\nusing namespace std ;\n\n#define ar array< int , 2 >\n\nclass Solution {\n\n int go( vector< ar > &A )\n {\n if(A.size() <= 1 )\n return A.size() ;\n\n int N = A.size();\n sort( A.begin() , A.end() );\n\n vector<int>t(N,0);\n t[... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Java | Index+k | Index+k+1 | Odd -Even | Expansion | Greedy | java-indexk-indexk1-odd-even-expansion-g-wdkt | Intuition\n Describe your first thoughts on how to solve this problem. \nExpand from element till k and check for k length palindrome else check for k+i length | walichandpasha | NORMAL | 2024-02-10T04:42:32.582058+00:00 | 2024-02-10T04:42:32.582081+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nExpand from element till k and check for k length palindrome else check for k+i length palindrome\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe will go to each element and check for both even and odd length of... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Java | Index+k | Index+k+1 | Odd -Even | Expansion | Greedy | java-indexk-indexk1-odd-even-expansion-g-jen0 | Intuition\n Describe your first thoughts on how to solve this problem. \nExpand from element till k and check for k length palindrome else check for k+i length | walichandpasha | NORMAL | 2024-02-10T04:42:31.216442+00:00 | 2024-02-10T04:42:31.216479+00:00 | 2 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nExpand from element till k and check for k length palindrome else check for k+i length palindrome\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe will go to each element and check for both even and odd length of... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | DP+LIS | dplis-by-trunkunala-3ba7 | Intuition\nThe idea is to record index pairs for all palindromic substrings within the string s, and then perform a Longest Increasing Sequence on it.\n\n# Appr | trunkunala | NORMAL | 2024-02-06T07:32:47.413376+00:00 | 2024-02-06T07:32:47.413400+00:00 | 21 | false | # Intuition\nThe idea is to record index pairs for all palindromic substrings within the string s, and then perform a Longest Increasing Sequence on it.\n\n# Approach\n*Step 1:* Create the boolean array to record all left-right index pairs of palindrome.\n*Step 2:* Record these pairs, and perform an LIS \n\n\n# Code\n`... | 0 | 0 | ['Dynamic Programming', 'Memoization', 'Java'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | 💡💡 Center expansion with non overlapping intervals solution in python | center-expansion-with-non-overlapping-in-8d78 | Intuition\n Describe your first thoughts on how to solve this problem. \nFind out even and odd lengted palindromes using center expansion and include them in th | shrishtikarkera | NORMAL | 2024-01-23T21:44:40.634959+00:00 | 2024-01-23T21:44:40.634987+00:00 | 5 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFind out even and odd lengted palindromes using center expansion and include them in the intervals list if the palindromic length is >= k. Now get the number of non overlapping intervals and return those. \n\n# Approach\n<!-- Describe you... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | O(n^2) Sol with easy loops without DP and extra space | on2-sol-with-easy-loops-without-dp-and-e-mwhm | Intuition\n Describe your first thoughts on how to solve this problem. \n1. Check pal at each char\n2. Make sure to check two ways Expanding wodnow (i, i) and | Bulls_eye1 | NORMAL | 2024-01-22T21:57:53.723335+00:00 | 2024-01-22T21:57:53.723356+00:00 | 1 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. Check pal at each char\n2. Make sure to check two ways Expanding wodnow (i, i) and (i, i + 1)\n3. If found adjust your out loop next ith iteration\n4. greedy to look for minimum pal \n\n\n# Approach\n<!-- Describe your approach to sol... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Front partition | front-partition-by-chakit_bhandari-zekh | Intuition\nAt each index i we have a choice whether to at each particular indices ending at j=i+k-1...n-1 or start at a new position i+1. Take the maximum out o | Chakit_Bhandari | NORMAL | 2023-12-07T19:22:42.897607+00:00 | 2023-12-07T19:22:42.897634+00:00 | 4 | false | # Intuition\nAt each index $$i$$ we have a choice whether to at each particular indices ending at $$j=i+k-1...n-1$$ or start at a new position $$i+1$$. Take the maximum out of these choices and return the ans.\n\n# Complexity\n- Time complexity: $$O(n*n)$$\n- Space complexity: $$O(n*n)$$\n\n# Code\n```\nclass Solution ... | 0 | 0 | ['Dynamic Programming', 'C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | 0/1 Knapsack pattern | 01-knapsack-pattern-by-chakit_bhandari-58dg | Intuition\nAt each index j we have three choices.\nEither we can end a substring at this position if s[i..j] is a palindrome\nOR\nWe can a end a substring at an | Chakit_Bhandari | NORMAL | 2023-12-07T19:20:25.149960+00:00 | 2023-12-07T19:20:25.149996+00:00 | 1 | false | # Intuition\nAt each index $$j$$ we have three choices.\nEither we can end a substring at this position if $$s[i..j]$$ is a palindrome\nOR\nWe can a end a substring at an index greater than $$j$$ in which case length still remains atleast $$k$$\nOR\nWe can start a new string at index $$i+1$$ and end at $$i+k$$.\n\nTake... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-non-overlapping-palindrome-substrings | Koltin | Approach Explained | Beats 100% | koltin-approach-explained-beats-100-by-m-27tt | Intuition\nThis problem is a combination of Non-overlapping intervals and Number of Palindromic Substrings\nhttps://leetcode.com/problems/non-overlapping-interv | Mahoraga_JJK | NORMAL | 2023-12-05T21:13:23.474835+00:00 | 2023-12-05T21:13:23.474889+00:00 | 3 | false | # Intuition\nThis problem is a combination of Non-overlapping intervals and Number of Palindromic Substrings\nhttps://leetcode.com/problems/non-overlapping-intervals/\nhttps://leetcode.com/problems/palindromic-substrings/\n\n# Approach\nStart by finding all palindromic substrings with length >= k and update result acco... | 0 | 0 | ['Kotlin'] | 0 |
count-substrings-with-k-frequency-characters-i | [Java/C++/Python] Sliding Window, O(n) | javacpython-sliding-window-on-by-lee215-91da | Intuition\n(n + 1) * n // 2 substrings in total.\nFind the number of substrings,\neach char appears at most k - 1 times.\n\n\n# Intuition2\nNo problem II in th | lee215 | NORMAL | 2024-10-20T04:12:51.736151+00:00 | 2024-10-20T04:27:49.706265+00:00 | 3,302 | false | # **Intuition**\n`(n + 1) * n // 2` substrings in total.\nFind the number of substrings,\neach char appears at most `k - 1` times.\n<br>\n\n# **Intuition2**\nNo problem **II** in the contest?\nUpvote this solution,\nand submit it directly in next contest!\n<br>\n\n# **Explanation**\nSolve with sliding window:\n\nEach ... | 54 | 4 | ['C', 'Python', 'Java'] | 8 |
count-substrings-with-k-frequency-characters-i | Easiest Solution 🔥✅ | Sliding Window | BEATS 94.94% | easiest-solution-sliding-window-beats-94-auol | Intuition\nWe need to count substrings where at least one character appears exactly k times. A sliding window approach helps us track character frequencies and | 1AFN19tfV2 | NORMAL | 2024-10-20T04:01:54.384958+00:00 | 2024-10-23T16:27:34.579349+00:00 | 2,883 | false | # Intuition\nWe need to count substrings where at least one character appears exactly `k` times. A sliding window approach helps us track character frequencies and adjust the window to find valid substrings efficiently.\n\n# Approach\n1. Use a sliding window with a pointer `l` and a frequency map `d` to track character... | 26 | 0 | ['Sliding Window', 'C++', 'Java', 'Python3'] | 5 |
count-substrings-with-k-frequency-characters-i | Simple Java Solution ✅ | simple-java-solution-by-shubhamyadav3210-xvzu | Approach\n- I used a nested loop to examine each substring. \n- For each starting point, I tracked character frequencies and checked if any character\'s frequen | shubhamyadav32100 | NORMAL | 2024-10-20T04:02:56.189189+00:00 | 2024-10-20T10:46:15.612814+00:00 | 1,124 | false | # Approach\n- I used a nested loop to examine each substring. \n- For each starting point, I tracked character frequencies and checked if any character\'s frequency reached `k`. \n- If it did, I counted all remaining substrings from that point onward.\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n- Space complexity: ... | 23 | 0 | ['Java'] | 1 |
count-substrings-with-k-frequency-characters-i | 🌟 Beats 100.00% 👏 || Count Sub strings With K-Frequency Characters I | beats-10000-count-sub-strings-with-k-fre-h2l4 | Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem revolves around counting substrings of a string s where a specific charact | srinivas_bodduru | NORMAL | 2024-10-20T08:22:09.051966+00:00 | 2024-10-20T08:22:09.051996+00:00 | 1,006 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem revolves around counting substrings of a string s where a specific character appears exactly k times. \n\nIterate through the string: For every starting point i in the string, consider every possible substring starting at i a... | 14 | 0 | ['Recursion', 'C', 'Simulation', 'Python', 'C++', 'Java', 'TypeScript', 'Python3', 'JavaScript'] | 3 |
count-substrings-with-k-frequency-characters-i | Simple Brute Force | simple-brute-force-by-_sxrthakk-zmwn | Intuition\n#### The key idea is to explore all possible substrings of s and, for each substring, check if any character appears k or more times. This can be don | _sxrthakk | NORMAL | 2024-10-20T04:02:00.502780+00:00 | 2024-10-20T04:02:00.502809+00:00 | 818 | false | # Intuition\n#### The key idea is to explore all possible substrings of s and, for each substring, check if any character appears k or more times. This can be done by generating all substrings and counting the frequency of each character for each substring. If at least one character satisfies the condition of appearing... | 10 | 0 | ['Python', 'C++', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | O(n) | on-by-votrubac-e5c6 | We expand the sliding window, maintaining the count of each character in cnt.\n\nWhen we cnt[ch] becomes k, we increase the number of "k+" characters ch_k.\n\nW | votrubac | NORMAL | 2024-10-20T06:48:35.888883+00:00 | 2024-10-20T06:54:46.561812+00:00 | 530 | false | We expand the sliding window, maintaining the count of each character in `cnt`.\n\nWhen we `cnt[ch]` becomes `k`, we increase the number of "k+" characters `ch_k`.\n\nWhen `ch_k` is positive, we find `len(s) - i` substrings.\n\nWe then shrink our window until `ch_k` becomes zero.\n\n**C++**\n```cpp\nint numberOfSubstri... | 9 | 0 | ['C'] | 1 |
count-substrings-with-k-frequency-characters-i | Easy Explained || O(n) || Two Pointer Approach | easy-explained-on-two-pointer-approach-b-x1u3 | Approach:\n\nWe can solve this problem using the sliding window (or two-pointer) technique along with character frequency counting. The main idea is to maintain | nikhiljangra264 | NORMAL | 2024-10-20T04:22:38.711228+00:00 | 2024-10-20T05:03:47.479312+00:00 | 514 | false | # Approach:\n\nWe can solve this problem using the **sliding window** (or two-pointer) technique along with character frequency counting. The main idea is to maintain a window `[i, j]` such that `s[j]` in the window appears `k` times.\n\n# Steps:\n\n1. **Sliding Window Setup:**\n - Use two pointers `i` and `j` to rep... | 7 | 0 | ['C++'] | 1 |
count-substrings-with-k-frequency-characters-i | ⚠️ INTUITIVE EASY SOLUTION | intuitive-easy-solution-by-ramitgangwar-s0gi | \n\n# \uD83D\uDC93**_PLEASE CONSIDER UPVOTING_**\uD83D\uDC93\n\n \n\n\n\n# \u2B50 Intuition\nThe problem asks to count all substrings where at least one charact | ramitgangwar | NORMAL | 2024-10-20T04:01:36.918112+00:00 | 2024-10-20T04:01:36.918151+00:00 | 275 | false | <div align="center">\n\n# \uD83D\uDC93**_PLEASE CONSIDER UPVOTING_**\uD83D\uDC93\n\n</div>\n\n***\n\n# \u2B50 Intuition\nThe problem asks to count all substrings where at least one character appears at least `k` times. The key observation here is that, given a sliding window approach, once we find a substring where a c... | 6 | 0 | ['Sliding Window', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | Easiest HashMap solution! Detailed Explanation provided. | easiest-hashmap-solution-detailed-explan-mrlc | Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to store the frequency of each character in subtsring. So we need a map to coun | Varun_Haralalka | NORMAL | 2024-10-26T16:19:54.408559+00:00 | 2024-10-26T16:19:54.408584+00:00 | 37 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to store the frequency of each character in subtsring. So we need a map to count. Now We go for the Brute force approach to form all substrings starting at each index. However we don\'t need to actually form them. We just need to ... | 3 | 0 | ['Hash Table', 'String', 'C++'] | 0 |
count-substrings-with-k-frequency-characters-i | Super Simple Sliding Window Count Java(O(n*n)) | super-simple-sliding-window-count-javaon-81ub | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1. find a window where | rajnarayansharma110 | NORMAL | 2024-10-20T08:20:13.090925+00:00 | 2024-10-20T08:20:13.090957+00:00 | 22 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. find a window where any freq>=k and add all the window from that point to n-1(n-r)\n# Complexity\n- Time complexity:O(n*n)\n<!-- Add your time complexity here, e.g.... | 3 | 0 | ['Java'] | 0 |
count-substrings-with-k-frequency-characters-i | Easy straightforward approach | easy-straightforward-approach-by-siddhuu-zi2k | Intuition\nTo solve the problem of counting substrings that contain at least k occurrences of any character, I initially thought about iterating through all pos | siddhuuse | NORMAL | 2024-10-20T06:33:32.337802+00:00 | 2024-10-20T06:33:32.337838+00:00 | 146 | false | # Intuition\nTo solve the problem of counting substrings that contain at least `k` occurrences of any character, I initially thought about iterating through all possible substrings of the given string `s`. For each substring, I could count the occurrences of each character and check if any of them met the requirement o... | 3 | 0 | ['String', 'Sliding Window', 'Python3'] | 0 |
count-substrings-with-k-frequency-characters-i | Easy to understand approach using HashMap | easy-to-understand-approach-using-hashma-1yx2 | Intuition\n Describe your first thoughts on how to solve this problem. \nGenerate all substring and maintain a hashmap to store count of letters and for every c | MainFrameKuznetSov | NORMAL | 2024-10-20T04:27:32.396959+00:00 | 2024-10-20T04:27:32.396982+00:00 | 53 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGenerate all substring and maintain a hashmap to store count of letters and for every character appearing atleast k times, increase the count.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGreedily generate all sub... | 3 | 0 | ['Hash Table', 'String', 'C++'] | 0 |
count-substrings-with-k-frequency-characters-i | Java Clean Solution | Weekly Contest | java-clean-solution-weekly-contest-by-sh-0kbe | Code\njava []\nclass Solution {\n private boolean helper(int[] freq, int k){\n for(int f:freq){\n if(f>=k){\n return true;\n | Shree_Govind_Jee | NORMAL | 2024-10-20T04:02:12.272003+00:00 | 2024-10-20T04:02:12.272037+00:00 | 225 | false | # Code\n```java []\nclass Solution {\n private boolean helper(int[] freq, int k){\n for(int f:freq){\n if(f>=k){\n return true;\n }\n }\n return false;\n }\n \n public int numberOfSubstrings(String s, int k) {\n int n = s.length();\n \n... | 3 | 0 | ['Math', 'String', 'String Matching', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | Brute force (All Substrings) >> Optimal (Sliding Window) | brute-force-all-substrings-optimal-slidi-mbb2 | \n# Brute Force\n\n\nclass Solution {\npublic:\n \n int subs(const string &s, int k) {\n int n = s.length(); \n int cnt = 0;\n for (i | sirius_108 | NORMAL | 2024-10-20T04:02:09.912106+00:00 | 2024-10-20T04:08:29.280848+00:00 | 214 | false | \n# Brute Force\n\n```\nclass Solution {\npublic:\n \n int subs(const string &s, int k) {\n int n = s.length(); \n int cnt = 0;\n for (int i = 0; i < n; ++i) {\n for (int j = i + 1; j <= n; ++j) {\n\n string x = s.substr(i, j - i);\n unordered_map<char... | 3 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | Sliding window, O(n) java solution | sliding-window-on-java-solution-by-11abh-k020 | Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n# Code | 11abhishekgg | NORMAL | 2024-10-22T18:44:04.749578+00:00 | 2024-10-22T18:44:04.749630+00:00 | 34 | false | # Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n public int numberOfSubstrings(String s, int k) {\n int result = 0, n = s.length(), start = 0;... | 2 | 0 | ['Java'] | 1 |
count-substrings-with-k-frequency-characters-i | Sliding window + counting | 8 ms - beats 100.00% | sliding-window-counting-8-ms-beats-10000-e12s | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\nwher | tigprog | NORMAL | 2024-10-20T13:43:41.689640+00:00 | 2024-10-20T13:43:41.689677+00:00 | 186 | false | # Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\nwhere `n = s.length <= 3000`\n\n# Code\n```python3 []\nclass Solution:\n def numberOfSubstrings(self, s: str, k: int) -> int:\n ... | 2 | 0 | ['Two Pointers', 'Sliding Window', 'Counting', 'Python3'] | 1 |
count-substrings-with-k-frequency-characters-i | Simple Brute Force || Substring ✅ | simple-brute-force-substring-by-harshsha-qatl | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Harshsharma08 | NORMAL | 2024-10-20T04:24:16.720175+00:00 | 2024-10-20T04:24:16.720198+00:00 | 183 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['String', 'C++', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | easy to learn | easy-to-learn-by-izer-bycv | Intuition\n Describe your first thoughts on how to solve this problem. \nwe have to count substring having at least one char fre. at leat k\n\n# Approach\n Desc | izer | NORMAL | 2024-10-20T04:18:15.975261+00:00 | 2024-10-20T04:18:15.975287+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe have to count substring having at least one char fre. at leat k\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfind all bossible substring \ncheck occurrence of char \nif we find even a case that is correct the... | 2 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | BEATS 90% || BEST BEGINNER CODE || SLIDING WINDOW || C++ | beats-90-best-beginner-code-sliding-wind-p09t | Intuition\nTo find the number of substrings that contain at least \'k\' occurrences of each character, we can use the sliding window technique. By adjusting the | LeadingTheAbyss | NORMAL | 2024-10-31T20:42:27.683959+00:00 | 2024-10-31T20:42:27.684001+00:00 | 38 | false | # Intuition\nTo find the number of substrings that contain at least \'k\' occurrences of each character, we can use the sliding window technique. By adjusting the window size based on the character counts, we can efficiently count valid substrings.\n\n# Approach\n1. Initialize a variable `res` to the total number of su... | 1 | 0 | ['Hash Table', 'String', 'Sliding Window', 'C++'] | 0 |
count-substrings-with-k-frequency-characters-i | O(n) solution using sliding window and hash map. Intuition and approach explained. Beginner friendly | on-solution-using-sliding-window-and-has-e8pf | Intuition\n Describe your first thoughts on how to solve this problem. \nMy first thought on seeing "counting substrings satisfying some condition..." was to us | beluuga7 | NORMAL | 2024-10-25T17:55:01.359625+00:00 | 2024-10-25T17:59:32.278695+00:00 | 30 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMy first thought on seeing "counting substrings satisfying some condition..." was to use sliding window technique.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSince it involved frequency of characters, we would... | 1 | 0 | ['Hash Table', 'String', 'Sliding Window', 'C++'] | 0 |
count-substrings-with-k-frequency-characters-i | HashMap soln || O(n2) approach || Easy to understand | hashmap-soln-on2-approach-easy-to-unders-nws8 | Complexity\n- Time complexity:\nO(n2)\n\n- Space complexity:\nO(n)\n\n# Code\njava []\nclass Solution {\n public int numberOfSubstrings(String s, int k) {\n | Amar_1 | NORMAL | 2024-10-20T20:40:18.893529+00:00 | 2024-10-20T20:40:18.893555+00:00 | 7 | false | # Complexity\n- Time complexity:\nO(n2)\n\n- Space complexity:\nO(n)\n\n# Code\n```java []\nclass Solution {\n public int numberOfSubstrings(String s, int k) {\n int count = 0;\n int n = s.length();\n\n for(int i = 0; i < s.length(); i++){\n HashMap<Character, Integer> map = new HashM... | 1 | 0 | ['Java'] | 0 |
count-substrings-with-k-frequency-characters-i | Simple C++ Solution ✅✅ | simple-c-solution-by-abhi242-t8wu | Code\ncpp []\nclass Solution {\npublic:\n int numberOfSubstrings(string s, int k) {\n int n=s.length();\n int ans=0;\n for(int i=0;i<n;i | Abhi242 | NORMAL | 2024-10-20T19:08:37.656797+00:00 | 2024-10-20T19:08:37.656818+00:00 | 16 | false | # Code\n```cpp []\nclass Solution {\npublic:\n int numberOfSubstrings(string s, int k) {\n int n=s.length();\n int ans=0;\n for(int i=0;i<n;i++){\n unordered_map<char,int> mp;\n for(int j=i;j<n;j++){\n mp[s[j]]++;\n if(mp[s[j]]>=k){\n ... | 1 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | 100% Beats || Sliding Window Approach || JAVA | 100-beats-sliding-window-approach-java-b-wnp6 | Intuition\n Describe your first thoughts on how to solve this problem. \n1. 100% BEATS\n2. Sliding Window Approach.\n\n# Approach\n Describe your approach to so | abhishekGaikwad96 | NORMAL | 2024-10-20T10:34:39.270961+00:00 | 2024-10-20T10:34:39.270980+00:00 | 48 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. 100% BEATS\n2. Sliding Window Approach.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**Here we will use sliding window approach.And for every window we will contain an array of character which will contain th... | 1 | 0 | ['Java'] | 0 |
count-substrings-with-k-frequency-characters-i | easiest JAVA solution by creating a frequency array.... BRUTE FORCE .... | easiest-java-solution-by-creating-a-freq-kun1 | Intuition\n Describe your first thoughts on how to solve this problem. \napplying sliding window approach and keeping track of the frequency of characters and | coder_neeraj123 | NORMAL | 2024-10-20T09:26:30.359325+00:00 | 2024-10-20T09:26:30.359351+00:00 | 16 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\napplying sliding window approach and keeping track of the frequency of characters and counting valid substrings \n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirst increase the size of the window until you get a ... | 1 | 0 | ['Java'] | 1 |
count-substrings-with-k-frequency-characters-i | Easy to understand Java Solution | O(n) | easy-to-understand-java-solution-on-by-v-c2y4 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | vg_85 | NORMAL | 2024-10-20T06:51:44.676497+00:00 | 2024-10-20T06:51:44.676529+00:00 | 17 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Sliding Window', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | ✅✅✅🤫Easy Solution Optimised BruteForce | easy-solution-optimised-bruteforce-by-ro-hx0m | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Royalking12 | NORMAL | 2024-10-20T06:46:48.179726+00:00 | 2024-10-20T06:46:48.179764+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | Sliding Window + HashMap | sliding-window-hashmap-by-himanshu_gahlo-t4jk | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1.Sliding Window Setup: | Himanshu_Gahlot | NORMAL | 2024-10-20T06:01:31.538109+00:00 | 2024-10-20T06:01:31.538142+00:00 | 8 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.Sliding Window Setup: I maintain two pointers, i and j, where i represents the starting index and j represents the ending index of the current window (substring) und... | 1 | 0 | ['Java'] | 0 |
count-substrings-with-k-frequency-characters-i | Simple Solution || Sliding Window || Time: O(n) and Space: O(1) | simple-solution-sliding-window-time-on-a-nzu1 | Approach\n Describe your approach to solving the problem. \n- Assume all are valid senarios and compute the total number of cases which is n(n + 1) / 2.\n- Now | godabauday | NORMAL | 2024-10-20T05:44:54.665341+00:00 | 2024-10-20T05:44:54.665364+00:00 | 158 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n- Assume all are valid senarios and compute the total number of cases which is **n(n + 1) / 2**.\n- Now remove the substrings which are invalid.\n\n# Complexity\n- Time complexity: **O(n)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- S... | 1 | 0 | ['Array', 'Hash Table', 'Math', 'Sliding Window', 'Python3'] | 0 |
count-substrings-with-k-frequency-characters-i | TC : O(n), SC : O(26) | tc-on-sc-o26-by-konavivekramakrishna3747-6zi1 | \n\n\n# Approach\n Describe your approach to solving the problem. \nTwo pointer approach (Sliding Window)\n\nTC : O(2n) ~ (n)\nSC : O(26) ~ O(1)\n\n\n\n# Code\n | kvrk | NORMAL | 2024-10-20T05:11:44.557581+00:00 | 2024-10-20T05:11:44.557608+00:00 | 24 | false | \n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTwo pointer approach (Sliding Window)\n\nTC : O(2n) ~ (n)\nSC : O(26) ~ O(1)\n\n\n\n# Code\n```python3 []\nclass Solution:\n def numberOfSubstrings(self, s: str, k: int) -> int:\n \n freq = [0] * 26\n low = 0\n cou... | 1 | 0 | ['Python3'] | 0 |
count-substrings-with-k-frequency-characters-i | Sliding window approach with O(n) TC and O(1) SC | sliding-window-approach-with-on-tc-and-o-ufxu | Intuition\nSince its a substring problem, the intuition is to use sliding window\n\n# Approach\nEvery time a valid substring is found, all the characters after | spoorthibasu | NORMAL | 2024-10-20T05:01:07.433337+00:00 | 2024-10-20T05:14:06.380721+00:00 | 22 | false | # Intuition\nSince its a substring problem, the intuition is to use sliding window\n\n# Approach\nEvery time a valid substring is found, all the characters after the end of that substring is still valid until the end of the given string. \nEx: abacb and k = 2,\nif, "aba" substring is valid\nthen all the substrings till... | 1 | 0 | ['Sliding Window', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | ✨Easy Approach CPP ||💪Beats 100.00% ||✅✅☑️☑️ | easy-approach-cpp-beats-10000-by-swapnee-w5ca | Approach:\n# Initialize Variables:\n\n- Use an integer totalCount to keep track of the total valid substrings.\n- Use a vector of size 26 (for each lowercase le | swapneel_singh | NORMAL | 2024-10-20T04:13:34.808064+00:00 | 2024-10-20T04:13:34.808096+00:00 | 235 | false | # Approach:\n# Initialize Variables:\n\n- Use an integer totalCount to keep track of the total valid substrings.\n- Use a vector<int> of size 26 (for each lowercase letter) to store the frequency of characters in the current sliding window.\n- Set up two pointers, left and right, to represent the current window of char... | 1 | 0 | ['C++'] | 2 |
count-substrings-with-k-frequency-characters-i | C++ | 100% beats | c-100-beats-by-gourav_1_2_3_r-p8j8 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Gourav_1_2_3_r_ | NORMAL | 2024-10-20T04:10:19.160771+00:00 | 2024-10-20T04:10:19.160823+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | 13MS || 100 % || Optimised solution || Java Solution | 13ms-100-optimised-solution-java-solutio-uc87 | Intuition\nWe are tasked with finding the number of substrings where at least one character appears k or more times. The key idea is to use a sliding window tec | yallavamsipavan1234 | NORMAL | 2024-10-20T04:10:14.990949+00:00 | 2024-10-20T04:10:14.990984+00:00 | 34 | false | # Intuition\nWe are tasked with finding the number of substrings where at least one character appears k or more times. The key idea is to use a sliding window technique to explore every substring, and for each substring, we check if a character appears k or more times. If such a substring is found, all suffix substring... | 1 | 0 | ['Array', 'String', 'String Matching', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | Basic approach, Direct Way | basic-approach-direct-way-by-sai116-qvfw | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Sai116 | NORMAL | 2024-10-20T04:01:29.949791+00:00 | 2024-10-20T05:37:26.877356+00:00 | 54 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Hash Table', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | sliding window beats 100% | sliding-window-beats-100-by-kakileti_mur-s64c | IntuitionApproach
Initialize sliding window:
Use unordered_map m to track character frequencies.
Set left = 0, and count = 0 for valid substrings.
Expand t | kakileti_Murari | NORMAL | 2025-04-11T10:10:27.943626+00:00 | 2025-04-11T10:10:27.943626+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
1. **Initialize sliding window**:
- Use `unordered_map m` to track character frequencies.
- Set `left = 0`, and `count = 0` for valid substrings.
2. **Expand the wi... | 0 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | O(n) Solution beat 100% | on-solution-beat-100-by-nitin_patel04-ivek | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | nitin_patel04 | NORMAL | 2025-04-04T08:43:04.287715+00:00 | 2025-04-04T08:43:04.287715+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | easy sliding window (java) | easy-sliding-window-java-by-dpasala-kyho | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | dpasala | NORMAL | 2025-04-03T17:45:10.476820+00:00 | 2025-04-03T17:45:10.476820+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Sliding Window', 'Java'] | 0 |
count-substrings-with-k-frequency-characters-i | A bit different interesting approach (not sliding window) | a-bit-different-interesting-approach-not-v63v | IntuitionThis solution tracks positions where characters reach frequency k, then counts valid substrings by determining all possible starting positions that pai | shmirrakhimov | NORMAL | 2025-03-20T10:32:45.825042+00:00 | 2025-03-20T10:32:45.825042+00:00 | 2 | false | # Intuition
This solution tracks positions where characters reach frequency k, then counts valid substrings by determining all possible starting positions that pair with each ending position.
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
1) Track Character Positions: For each characte... | 0 | 0 | ['Hash Table', 'String', 'JavaScript'] | 0 |
count-substrings-with-k-frequency-characters-i | C++ sliding window approach Time: O(n) Space: O(n) beat 100%!! | c-sliding-window-approach-time-on-space-sne35 | Approachkeeps open window till find there is a char freq is greater than k,
and all the subarray including current one will all be the answer.Once we update the | chienwade5960 | NORMAL | 2025-03-12T05:40:50.850763+00:00 | 2025-03-12T05:40:50.850763+00:00 | 1 | false | # Approach
<!-- Describe your approach to solving the problem. -->
keeps open window till find there is a char freq is greater than k,
and all the subarray including current one will all be the answer.
Once we update the answer then close window to check the condition still meet or not
# Complexity
- Time complexity:
... | 0 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | C++ | sliding window | c-sliding-window-by-kena7-p50w | ApproachSliding windowComplexity
Time complexity:
O(n*26)
Space complexity:
O(26)
Code | kenA7 | NORMAL | 2025-03-08T13:41:46.171736+00:00 | 2025-03-08T13:41:46.171736+00:00 | 1 | false | # Approach
Sliding window
# Complexity
- Time complexity:
O(n*26)
- Space complexity:
O(26)
# Code
```cpp []
class Solution {
public:
bool good(vector<int> &count,int k)
{
for(auto &x:count)
if(x>=k)
return true;
return false;
}
int numberOfSubstrings(stri... | 0 | 0 | ['C++'] | 0 |
count-substrings-with-k-frequency-characters-i | Golang solution | golang-solution-by-sudarshan_a_m-izuk | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Sudarshan_A_M | NORMAL | 2025-02-28T05:12:23.547040+00:00 | 2025-02-28T05:12:23.547040+00:00 | 4 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Go'] | 0 |
count-substrings-with-k-frequency-characters-i | easy solution | easy-solution-by-owenwu4-z08x | Intuitionuse n2ApproachComplexity
Time complexity:
Space complexity:
Code | owenwu4 | NORMAL | 2025-02-19T02:12:24.412050+00:00 | 2025-02-19T02:12:24.412050+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
use n2
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
... | 0 | 0 | ['Python3'] | 0 |
count-substrings-with-k-frequency-characters-i | 100% Java Solution✔✔✔⚡⚡⚡ | 100-java-solution-by-shubhamrathore24-0jux | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | shubhamrathore24 | NORMAL | 2025-02-17T19:05:23.308993+00:00 | 2025-02-17T19:05:23.308993+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Java'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.