Remove Colored Pieces if Both Neighbors are the Same Color | Intuitive | GOOGLE | Leetcode - 2038

  Рет қаралды 3,428

codestorywithMIK

codestorywithMIK

Күн бұрын

This is the 19th Video on our Greedy Playlist.
In this video we will try to solve a very good Greedy Problem - Remove Colored Pieces if Both Neighbors are the Same Color (Leetcode-2038).
Trust me, this will no longer be a Medium Problem.
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Remove Colored Pieces if Both Neighbors are the Same Color
Company Tags : GOOGLE
My solutions on Github : github.com/MAZ...
Leetcode Link : leetcode.com/p...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZ...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook

Пікірлер: 48
@rohankadam7376
@rohankadam7376 10 ай бұрын
IF SOMEONE IS LOOKING FOR JS SOLUTION :- var winnerOfGame = function(colors) { var aliceCount = 0 var bobCount = 0 var n = colors.length; for(let i=1;ibobCount ? true : false; };
@HarshitKumar-gn5wf
@HarshitKumar-gn5wf Жыл бұрын
regreting now, should thought a little more on this, such a easy question for medium level
@gui-codes
@gui-codes 2 ай бұрын
fabulous explanation.
@nehakhatri3921
@nehakhatri3921 6 ай бұрын
Wow kya samjhaya hai
@anuppatankar4294
@anuppatankar4294 Жыл бұрын
Great Video 😍
@shabananoor9423
@shabananoor9423 Жыл бұрын
❤❤❤❤❤
@harshkishorani3101
@harshkishorani3101 Жыл бұрын
Man I love your explanations for Daily Leetcoding challenges! You really help me out. Thanks Man.
@AnadiHirpara
@AnadiHirpara Жыл бұрын
bhai comparator ki sereis chalu kro na mene apki playlist me dhundhi lekin nai mili
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sure thing Let me plan as soon as I get back to India
@invinciblearmyvlogsshorts7911
@invinciblearmyvlogsshorts7911 Жыл бұрын
DSA has become fun becz of you...
@onesaditya3689
@onesaditya3689 Жыл бұрын
Sir we cannot remove the colors, we only count it. Sir how it print true when Alice>Bob pls explain it smthg.
@avnish-wf8rv
@avnish-wf8rv Жыл бұрын
question looks so complicated but its so easy. JAVA int countA = 0; int countB = 0; for (int i = 1; i < colors.length() - 1; i++) { if (colors.charAt(i - 1) == 'A' && colors.charAt(i + 1) == 'A' && colors.charAt(i) == 'A') { countA++; } if (colors.charAt(i - 1) == 'B' && colors.charAt(i + 1) == 'B' && colors.charAt(i) == 'B') { countB++; } } if (countA > countB) { return true; } return false;
@HARIOM_MISHRA
@HARIOM_MISHRA Жыл бұрын
Today i got toh onow how much i evolved myself in last 4months just watching ur videos today i tried to solve this question by myself and got the correct intuition same as u in my first attempt and did the question in just 2 mins i m too happy and thanku very much for evolving my thinking skill thanks alot
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you 🙏😇
@keertilata20
@keertilata20 Жыл бұрын
Was able to solve after the hints... bool winnerOfGame(string s) { int n=s.length(); if(n
@Abhay14
@Abhay14 Жыл бұрын
bhaiya maine ye && operator nhi lagaya maine aaise kiya mera kyun galat aaya bool winnerOfGame(string colors) { int alice = 0; int bob = 0; int n = colors.size(); for(int i=1; i bob){ return true; } return false; }
@k.vabhavmishra
@k.vabhavmishra Жыл бұрын
Can any one tell me what is wrong here ? bool winnerOfGame(string colors) { int n=colors .length(); string str1="AAA"; string str2="BBB"; int countA=0,countB=0; while(n>3){ if(countA>countB){ return true; break; } if(countB>countA) { return false; break; } if(colors.find(str1)!=string::npos){ int i =colors.find(str1); countA+=1; colors.erase(i+1,1); } if(colors.find(str2)!=string::npos){ int j=colors.find(str2); countB=+1; colors.erase(j+1,1); } } return countA > countB ?true :false; }
@Aaron-Barnes
@Aaron-Barnes Жыл бұрын
Thanks for simple explanation
@utsavbarnwal7120
@utsavbarnwal7120 Жыл бұрын
Bro , sheet ki video bnao
@Rishabhkumar-ug4qv
@Rishabhkumar-ug4qv Жыл бұрын
First
@RahulKumar-zp1ln
@RahulKumar-zp1ln Жыл бұрын
Mastt bhai mastt.
@codeandtalk6
@codeandtalk6 Жыл бұрын
You made it so easy thank you
@09avishkargaikwad71
@09avishkargaikwad71 Жыл бұрын
Another next level video from legend with outstanding explnation Hatts Off man!!! We would like to see your videos with leetcode weekly and Biweekly contest. Atleast for 3&4 questions ...
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you 🙏😇 Soon
@oqant0424
@oqant0424 Жыл бұрын
Explained it so well :)
@TheAI-Tutor
@TheAI-Tutor Жыл бұрын
Bhaiiiiii!!!!!!!!! Hats off to you bro, Tumhe meri dua milegi
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you 🙏😇
@sumitbaghel6203
@sumitbaghel6203 Жыл бұрын
I am in BOB's team😂😂
@dhairyachauhan6622
@dhairyachauhan6622 Жыл бұрын
# BRUTE ``` TIME: O(N^2) SPACE: O(N) ``` ``` INTUITION: - FIND THE PAIR MARK THE CENTER ELEMENT VISITED SO IT CANT BE USED AGAIN ``` ``` class Solution { public: vectorvisited; bool findPair(string &colors,char ch){ int n = colors.size(); for(int i = 1;i
@nagmakhan3165
@nagmakhan3165 Жыл бұрын
The intuition was lit 🔥
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
The best again😊
@kartikrameshchavan6662
@kartikrameshchavan6662 Жыл бұрын
Thanks Sir 🙏
@jagadeeshp1163
@jagadeeshp1163 8 ай бұрын
Done✅
@ugcwithaddi
@ugcwithaddi 11 ай бұрын
Legend
@codeandtalk6
@codeandtalk6 Жыл бұрын
❤❤
@HealthyOm
@HealthyOm Жыл бұрын
❤❤❤❤
@sayantanbandyopadhyay7803
@sayantanbandyopadhyay7803 Жыл бұрын
waiting for your video ...
@killshot57
@killshot57 Жыл бұрын
Masterful 🙆🏻‍♂️
@deepaksingh-qd7xm
@deepaksingh-qd7xm 5 ай бұрын
thought the same intuition but lazy to code 🙄🙄🥲🥲🥲🥲
@Momentsofmagic28
@Momentsofmagic28 Жыл бұрын
Loved the simplicity of the story. Just loved it. You are a magician.
@floatingpoint7629
@floatingpoint7629 Жыл бұрын
thanks for the explanation. it was very helpful
@AlishaKhan-ww3io
@AlishaKhan-ww3io Жыл бұрын
Big fan of your stories 🙌. Thanks a lot for making this easy
@MounikaEMB
@MounikaEMB Жыл бұрын
Very easy explanation👏 Thank you 😊
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
legit . You made it extremely simple
@rounaq_khandelwal
@rounaq_khandelwal Жыл бұрын
Your previous advice worked quite well for me!! I did well in prev contest held. and thanks for this video, was able to implement the logic as soon as i saw the greedy wallpaper at t=0
@k.vabhavmishra
@k.vabhavmishra Жыл бұрын
what was the advice can u tell?
@rounaq_khandelwal
@rounaq_khandelwal Жыл бұрын
@@k.vabhavmishra regarding dp and recursion, dry run is very imp!
@somsk56
@somsk56 Жыл бұрын
nice explanation 💗
Minimum Time to Make Rope Colorful | Greedy Intuition | Leetcode 1578
23:41
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,9 МЛН
How do Cats Eat Watermelon? 🍉
00:21
One More
Рет қаралды 11 МЛН
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 2,8 МЛН
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
Being Competent With Coding Is More Fun
11:13
TheVimeagen
Рет қаралды 85 М.
Harsh Truth of Java in 2024! Ft. Ultimate Java Developer @Telusko
28:46
Ep : 5 I Jain Philosophy: An Introduction I Dr Vikas Divyakirti
3:29:27
Vikas Divyakirti
Рет қаралды 9 МЛН
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 238 М.
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,9 МЛН