Leetcode 696. Count Binary Substrings || Code + Explanation + Example Walkthrough

  Рет қаралды 8,420

Code with Alisha

Code with Alisha

Күн бұрын

Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.
Substrings that occur multiple times are counted the number of times they occur.
Example 1:
Input: "00110011"
Output: 6
Explanation: There are 6 substrings that have equal number of consecutive 1's and 0's: "0011", "01", "1100", "10", "0011", and "01".
Notice that some of these substrings repeat and are counted the number of times they occur.
Also, "00110011" is not a valid substring because all the 0's (and 1's) are not grouped together.
Example 2:
Input: "10101"
Output: 4
Explanation: There are 4 substrings: "10", "01", "10", "01" that have equal number of consecutive 1's and 0's.

Пікірлер: 37
@janicelin9758
@janicelin9758 Жыл бұрын
I have watched 3 youtube videos for the same question, yours is the best explained about pre and current! I was so confused on why initial pre =0 and current =1, but your explain made a lot sense. Thank you!
@jerrywong5140
@jerrywong5140 2 жыл бұрын
This is the most detailed explanation of this question I can find on internet, thank you!
@metatech2787
@metatech2787 14 күн бұрын
great explanation i follow your playlist of each for problem solving
@shadaabiqbal4875
@shadaabiqbal4875 Жыл бұрын
I was asked the same question in the interview and was cross-questioned. The interviewer also asked to print all the substrings which I couldn't do. I got stuck. I can't solve it yet?
@tejakovvuri3042
@tejakovvuri3042 2 ай бұрын
Very clear explanation, thanks.
@johnj171
@johnj171 Ай бұрын
great solution I understand the concept
@theboss6488
@theboss6488 Жыл бұрын
great finally found a good solution which i can understand easily ...thanks ❤❤
@shachisinghal8856
@shachisinghal8856 Жыл бұрын
Amazing teaching!!!!! Thanku, wish college profs were like you.
@musicaccount6482
@musicaccount6482 11 ай бұрын
This is definitely a tricky question. Such a great explanation. Thank you 🙏
@kachhadiyasujal
@kachhadiyasujal 2 ай бұрын
nice explanation thank you
@user-hl8wf5bn3k
@user-hl8wf5bn3k 7 ай бұрын
Yours is the best explaination,u make it very easy. Please do upload more videos
@lakshsinghania
@lakshsinghania Жыл бұрын
thnx for the explanation! i was struggling in this problem being an easy problem
@Chirag12390
@Chirag12390 4 ай бұрын
Big fan mam ❤❤❤
@omkar._.k
@omkar._.k Ай бұрын
Asked in IBM test
@RAJ-np1iu
@RAJ-np1iu 2 жыл бұрын
gwadd lev explain...🤯🤓
@alviahmed7388
@alviahmed7388 10 ай бұрын
Okay this is a really elegant and easy to understand solution. How were you able to come up with the solution yourself? My algorithmic thinking is very weak still, how do i get better?
@f15srinivas82
@f15srinivas82 5 ай бұрын
superb
@nantuadhikari1280
@nantuadhikari1280 Жыл бұрын
love u di. such a simple and nice solution
@urmomapollo
@urmomapollo 3 жыл бұрын
this is an amazing explanation thanks so much!
@samprativishnoi9416
@samprativishnoi9416 2 жыл бұрын
best explanation
@musas.kanneh8344
@musas.kanneh8344 2 жыл бұрын
great explanation!
@AlgoXperience
@AlgoXperience Жыл бұрын
Great work yar
@thierrymanzi4596
@thierrymanzi4596 2 жыл бұрын
great explanation
@chennupativinaykumar2390
@chennupativinaykumar2390 2 жыл бұрын
Thank you
@sahilgogna3393
@sahilgogna3393 2 жыл бұрын
Thanks
@ashvinkumhar5819
@ashvinkumhar5819 2 жыл бұрын
great diii
@bostonlights2749
@bostonlights2749 2 жыл бұрын
awesome...
@amantiwari9275
@amantiwari9275 9 ай бұрын
how u come to this intution please explain
@greatred2558
@greatred2558 2 жыл бұрын
thx
@adarshkukreti9658
@adarshkukreti9658 2 жыл бұрын
good👍👍
@prasanthmaddiboina4151
@prasanthmaddiboina4151 3 жыл бұрын
mam can u explain the frequency of the most frequent element
@deepakgauttam29
@deepakgauttam29 Жыл бұрын
your leet code profile plzzz... .kindly share the link
@fishnimo6410
@fishnimo6410 3 жыл бұрын
what's your user name in leetcode ?
@shubhamgarg8229
@shubhamgarg8229 3 жыл бұрын
also, are you on CodeChef?
@devanshsinghla4677
@devanshsinghla4677 Жыл бұрын
Itna dimag kese lga lete ho???
@utkarshgautam1940
@utkarshgautam1940 Жыл бұрын
actually nice explanation
@kunalkheeva
@kunalkheeva Жыл бұрын
Best explanation, thank you.
Leetcode 2401. Longest Nice Subarray | Weekly Contest 2401.
19:54
Code with Alisha
Рет қаралды 6 М.
Magic or …? 😱 reveal video on profile 🫢
00:14
Andrey Grechka
Рет қаралды 61 МЛН
HOW CAN I ALWAYS STUDY?   | HOW DO I RISE MY MOTIVATION? | *animation*
7:26
Count Binary Substrings | LeetCode 696 | Coders Camp
9:40
Coders Camp
Рет қаралды 2,2 М.
Tell Me About Yourself | Best Answer (from former CEO)
5:15
The Companies Expert
Рет қаралды 6 МЛН
Google Coding Interview With A Competitive Programmer
54:17
Clément Mihailescu
Рет қаралды 2,5 МЛН
How To Read Text In Binary
3:29
Tom Scott
Рет қаралды 1,9 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
#Leetcode 45 Jump Game 2 || Code + Explanation + Example Walkthrough
12:42