Remove All Adjacent Duplicates In String | Removing consecutive duplicates | Stack Playlist Hindi
Vložit
- čas přidán 23. 02. 2022
- This is the video under the series of DATA STRUCTURE & ALGORITHM in a STACK Playlist. Now we are going to solve a stack problem in leetcode Remove All Adjacent Duplicates In String or Removing consecutive duplicates from GeeksForGeeks.
Join My Telegram channel for more Updates: telegram.me/helloworldbyprince
complete DSA preparation: github.com/Prince-1501/Comple...
----------------------------------------------------------------------------------------
► 1047. Remove All Adjacent Duplicates In String
You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.
We repeatedly make duplicate removals on s until we no longer can.
Return the final string after all such duplicate removals have been made. It can be proven that the answer is unique.
Input: s = "abbaca"
Output: "ca"
Explanation:
For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move. The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
►Remove All Adjacent Duplicates In String: leetcode.com/problems/remove-...
► Code In this video: github.com/Prince-1501/Hello_...
----------------------------------------------------------------------------------------
*Follow me *
LinkedIn► / iamprince
Facebook► / helloworldofficials
Instagram► / helloworldbyprince
Twitter► / prince_king_
Telegram► telegram.me/helloworldbyprince
----------------------------------------------------------------------------------------
►Our Playlists on:-
► Tree: • Tree Data Structure & ...
► Stack: • Stack & Queue Data Str...
► Hashing: • Hashing Data Structure...
► Graph: • Graph Data Structure &...
► Matrix: • Matrix (Multidimension...
► STL: • Standard Template Libr...
► Leetcode: • LeetCode Solutions And...
►Competitive Programming: • Full course in Competi...
►C++ Full Course : • C++ full Course in HINDI
►Algorithms: • L-01 || Prefix Sum Arr...
►Data Structure: • Data Structures with C...
------------------------------------------------------------------------
🌟 Please leave a LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
✨ Tags ✨
leetcode problems
leetcode problems java
leetcode problems python
leetcode problems that got me tired
leetcode problems c++
leetcode problems and solutions python
leetcode problems playlist
leetcode problems and solutions java
leetcode problems in Hindi
leetcode problems javascript
leetcode problems and solutions
leetcode problems of the day
leetcode problems for beginners
leetcode problems easy
leetcode problems js
Introduction to the graph data structure
Graph playlist Hello world
Shortest Path in Unweighted Graph
stack practice problems
stack practice problems gfg
leetcode stack questions
leetcode stack queue
stack hello world
remove all adjacent duplicates in string leetcode solution
remove all adjacent duplicates in string gfg
question asked in Google
off-campus placement
number of closed islands
Practice stack data structure
Stack in a data structure in Hindi
Stack Full playlist for Beginners
algorithms
graph
data structure
sorting algorithms
algorithm analysis
gate computer science preparation
programming languages
#stack #Leetcode #programming
Great Vid! Understtod the concepts well!
we can optimize it by iterating the string from end ,then no reversal of ans required
Great Explanation bhaiya...
Great Video & nyc explanation
just one question will this method works on "accca" o/p should be null string but it is giving "aca" acc to logic
Awesome Content ! Understood it in the first go.
Thanks for the support ☺️
great vid !
nyc explanation, Understood well
Thanks a lot
Thank u bhaiya
Loves your explanation from Hashing series 💜
That's great 😊
Thanks for the support
Awesome bhaiya ❤️
Thanks saurabh
best explanation
Maja hi aa gaya bhaiyya ekdum mast explanation tha
Thanks bro supporting me Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Amaging explanation 👌🙏
Thanks Nitesh
seen this question in deshaw interview so important question
Your are best sir...
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
sir your way of teaching is suprbb❤
love from jammu
Thanks a lot
thanks bhaiya for amazing explanation
Always welcome
Completed linked list now going for stack.
Feeling like "sahi teacher pakada gya hai "
Hope to see you in Ramgarh one day
sure yaar
Great sir very helpful video 👍
Thanks and welcome
Great vid
Such a nice explain Bhaiya
Thanks a lot
yes sir im present
Done . Nice Explanation.
Thanks and welcome
you are the best........masum.
Thanks a lot
Great video!
Thanks Anika
Ho gya Bhaiya pause kr k Gya
very good explanation
Keep watching
Great Video !
Thanks for the support ☺️
Nice video
Great👍
Thanks Pooja
bhaiya kya pdaate ho mja aa gya 👌👌👌👌😊😊😊
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Very helpful video
Glad it was helpful!
Good tutorial sir
Keep watching
thanks for this
u r welcome Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Fantastic
Thank you so much 😀
great
Thanks a lot
Great Video
keep learning Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
great video
Thanks for your support, Please share my channel
stackst;
what is st??
its the name of stack which we built or created
aap aur v kuch naam de sakte ho
Great
Thanks
🤩Great video ..........
Thanks 🤗
wow!
Thanks 👍
Done in 1st attempt , easy
string removeDuplicates(string s) {
stack st;
for (int i=0 ; i
Great job yaar
yeh code pe run karna acaaabbbacdddd
Present sir👁️
Yess
❤
Thanks
awesome content
thanks buddy
Why we can't use queque instead of stack ?
💯💯💯💯
Thanks yaar ❤️ please share and support my channel
Nice
Keep learning buddy
attandance🖐
Bhaiya plz el bar remove all occurance in the string explain krdo.. Plz i not getting the concept of substring
Present sir 👀
Attendance marked ✅
Sir, I'm unable to successfully submit this code. All the test cases pass but while submitting this one a "TIME LIMIT EXCEEDED" warning pops up. Can you help me with this?
add i++ in the end of while loop
present sir
attendance counted
Sir Following your playlist is helping me in thinking on own and approaching the questioon. love your way of explaining sir .❤🔥@@HelloWorldbyprince
leetcode 1047 cpp sol two approaches iterative and stacks :
class Solution {
public:
string removeDuplicates(string s) {
//1st approach->iterative
int i=0;
while(iindex,2 (1st element the index itself and 2nd its adjacent/next one)
s.erase(i,2);
if(i>0) i--;
}
else
i++;
}
return s;
//2nd approach(more optimised)->using stacks
//using stacks
stackst;
string ans="";//return type is string not string vector
//as LIFO so traverse from back so we wont be needed any reverse function later
for(int i=s.size()-1;i>=0;i--){
//condition check
//"while" loop dont make any sense as only one element would be inserted at a time so will be removed once if condition satisfies
if(!st.empty() && st.top()==s[i]){
st.pop();
continue;//skips the loop for that i
}
st.push(s[i]);
}
//traverse the stack and push elements into the array
while(!st.empty()){
ans.push_back(st.top());
st.pop();
}
return ans;
}
};
amazing code bro
Bhaiya / sir memory limit exceed show ho rha h same code
not possible, try to run my code
dont worry
dekh rahe hai
Okay 👍
Ans+= ele means ?? Bhaiya plz bol do baki samaj aa gaya
time limit exceeded dikha rha he
Solution is not working for "bbaab"
Please correct your solution
weel explain
Thanks a lot buddy
Present
Attendence++
attendance
nice bro attendance counted
support
Thanks
Trees done,graph done ,hashing done ,matrix done ,stack loading ,kisne bola hai koi nahi dekh raha
Don't accept this code on gfg
Check the language on gfg what u selected ?
Or make a line by line check my code with yours
Great👍
Thanks for the support
great
Thanks Ankit