Minimum Length of String After Deleting Similar Ends | Simple Two Pointers | Leetcode 1750

preview_player
Показать описание
This is the 7th Video of our Playlist "Two Pointers : Popular Interview Problems".
In this video we will try to solve a good problem : Minimum Length of String After Deleting Similar Ends | Leetcode 1750

Share your learnings on LinkedIn, Twitter (X), Instagram, Facebook(Meta) with #codestorywithmik & feel free to tag me.

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.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Minimum Length of String After Deleting Similar Ends | Leetcode 1750
Company Tags : AMAZON

Approach Summary :
The provided approach defines a class named `Solution` with a method `minimumLength`, which calculates and returns the minimum length of a string `s` after repeatedly removing identical characters from both ends. The algorithm uses two pointers (`i` and `j`) starting from the beginning and end of the string and iterates until these pointers meet or the characters at their positions are different. It then removes consecutive identical characters from both ends, updating the pointers accordingly. The final result is the length of the remaining substring after these removals. The `main` method demonstrates how to use this solution by providing an example input string.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

✨ Timelines✨
00:00 - Introduction
04:39 - 2 Pointers
06:46 - Dry Run
10:27 - Corner Case
14:54 - Live coding

#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 #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyearZ
Рекомендации по теме
Комментарии
Автор

you make each and every ques look very easy even if its the hardest one u make it look so simple type pls continue making such videos !

techbuddy-bw
Автор

i have been coding for the past 6 yrs still missed the corner case. moral of the story always dry run your code with all examples and till the last iteration!!!

mohammedyasser
Автор

Thanks sirji for you provide your important time🥰🥰

amankumar-igfe
Автор

easy peasy!!

kudh solve karne ki koshish ki par edge cases miss hogaye, T-T

test cases pass ho gaye te

thank you mik for covering the edge cases as well...

heyOrca
Автор

@codestorywithMIK sir pls can you make video on todays GFG POTD maximum index plsss

KavyaGupta
Автор

Rabin-Karp Algorithm please build video on this and special the theory part it is hard to understand

parthbhatti
Автор

why to use deque ?can use sub string function to calculate the remaining string also.

MaheshPatil-ofzy
Автор

sir please upload todays GFG POTD problem i.e RABIN KARP ALGORITHM

DeepakSingh-fdix
Автор

Thanks as always mik. Your clear voice and way of explanation solves all doubts

DevOpskagyaan
Автор

timeompleity O(n^2) nhi ghogi kya 2 while loop

sakshamshrivastava
Автор

Longest repeating and non-overlapping substring Bring video on this as well

parthbhatti
Автор

Me har problem apki video deke samjke karta hu par own se ni karpaata hu kya ki apki playlist follow Karu ya phir own se hi try karu

swagboltey
Автор

can you please make video on log like if interviewer asked what is log why we required log in time complexity ? etc.... and solve 1-2 problems and we will learn to find out the log time complexity ?

parthbhatti
Автор

bahiaya geeksforgeeks ke bhe dala kero please

infinitygaming
Автор

For follow up question why can't I use str.substring(I, j+1) for java. Is it still to use dequeue

santhosh
Автор

Is graph concepts playlist complete d?

ru
Автор

hey can anyone please tell me the problem with this code

int minimumLength(string s)
{
int n=s.size();
int i=0;
int j=n-1;
char previ='#';
char prevj='#';

while(i<=j)
{
if(s[i]==s[j])
{
previ=s[i];
prevj=s[j];
i++;
j--;
}

else if(s[i]==previ)
{
previ=s[i];
i++;
}

else if(s[j]==prevj)
{
prevj=s[j];
j++;
}

else
return j-i+1;
}
return 0;
}

lakshaykumar
welcome to shbcf.ru