One improvement you can make is increasing the volume a bit. Because I am listening to it at full volume and think that it can be increased a bit from your side. Explanation was good.
//Bruteforce Approach class Solution { public int numberOfSubstrings(String str) { int count = 0; for (int start = 0; start < str.length(); start++) { for (int end = start; end < str.length(); end++) { if ((end - start + 1) >= 3 && isValidSubstring(str, start, end)) { count++; } } } return count; } private boolean isValidSubstring(String str, int start, int end) { boolean foundA = false, foundB = false, foundC = false; for (int i = start; i 0 && frequency[1] > 0 && frequency[2] > 0) { // count all substrings that start from 'start' and end at any index from 'end' to the end of the string. count += str.length() - end; /* * Ex: aaabcaccaa * when start=0 and end=4 * * we have following valid subtrings: * "aaabc", "aaabca", "aaabcac", "aaabcacc", "aaabcacca", "aaabcaccaa". i.e str.length() - end * * similarly when start =1 and end =4 * * we have following valid subtrings: * "aabc", "aabca", "aabcac", "aabcacc", "aabcacca", "aabcaccaa". i.e str.length() - end */ // Shrink the window from the left frequency[str.charAt(start) - 'a']--; start++; } } return count; } }
Very structured and to the point video. Love it ❤
Nice Explanation 👍
keep doing
One improvement you can make is increasing the volume a bit. Because I am listening to it at full volume and think that it can be increased a bit from your side. Explanation was good.
Your teaching is very effective Mam.
Just put some time to discuss intuition, approach and complexity of the code.
Thank you, I will
best explanation ... most easy ♥
Glad to hear that
Please discuss Brute force approach & complexity .
Can you please do your explanation in English. It would help a wider range of audience.
Brilliant explanation
//Bruteforce Approach
class Solution {
public int numberOfSubstrings(String str) {
int count = 0;
for (int start = 0; start < str.length(); start++) {
for (int end = start; end < str.length(); end++) {
if ((end - start + 1) >= 3 && isValidSubstring(str, start, end)) {
count++;
}
}
}
return count;
}
private boolean isValidSubstring(String str, int start, int end) {
boolean foundA = false, foundB = false, foundC = false;
for (int i = start; i 0 && frequency[1] > 0 && frequency[2] > 0) {
// count all substrings that start from 'start' and end at any index from 'end' to the end of the string.
count += str.length() - end;
/*
* Ex: aaabcaccaa
* when start=0 and end=4
*
* we have following valid subtrings:
* "aaabc", "aaabca", "aaabcac", "aaabcacc", "aaabcacca", "aaabcaccaa". i.e str.length() - end
*
* similarly when start =1 and end =4
*
* we have following valid subtrings:
* "aabc", "aabca", "aabcac", "aabcacc", "aabcacca", "aabcaccaa". i.e str.length() - end
*/
// Shrink the window from the left
frequency[str.charAt(start) - 'a']--;
start++;
}
}
return count;
}
}
ur linkedin pls
First comment😂
Explanation kaisa tha uske bare me likh...😅
Good @@aakashpatel1250