LeetCode Remove All Adjacent Duplicates In String Solution Explained - Java

preview_player
Показать описание


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

short concise and easy to understand. Your way of teaching is perfect. Please keep it up

ravishraj
Автор

How do you handle when char is repeated odd no of times like if string is abbbac

strider_
Автор

Originally, I used two pointers instead of stack and it turned out to be really inefficient compared to stack. I really appreciate your stack explanation! :)

yusenpeng
Автор

O(1) space solution ...
Loop until arr(i) ==arr(i+1) then place 2 pointers a and b at I+2 and i-1 respectively, and check if elements are equal at those indices, if yes keep expanding the pointers a and b until the elements are not equal then delete.repeat everything till we reach the end of string

smithshelke
Автор

Request tutorial graph like a MST, djikstra shortest path

dharmaputra
Автор

That clap at the beginning blew my ear off 😅

theyashbansal
Автор

what was that noise in the starting of the video !!

_karan
Автор

the the way you programmed this question it is genius...

krishnavar
Автор

U r doing a very very great job thanx that I have found u in youtube.
I love your videos..
Love from India..❤💌

biswaranjanbarik
Автор

7:25 how does string from 0, 2 returns c, a. Instead of 0, 2 it should be 0, 1?

unknownman
Автор

why using a char[] as stack instead of using STACK ADT?

dalindu
Автор

I have never used stack with indices, can someone share me some problems, which use the same. Thanks.

ketansharma
Автор

Brother you didn’t write a 0 assignment in case there’s a duplicate how can stack change then ....

CodeSuccessChronicle
Автор

Can do with inplace string manipulation, without using extra memory (credit to you as I learnt this trick from your previous video, so thank you! :) )

guyfromgalaxy
Автор

It does not work with aaab result is ab should be b

samvid
Автор

It doesn't work for TC aabbccccbapq

varunsadhu
Автор

string removeDuplicates(string s) {
int i = 0, n = s.length();
for (int j = 0; j < n; ++j, ++i) {
s[i] = s[j];
if (i > 0 && s[i - 1] == s[i]) // count = 2
i -= 2;
}
return s.substr(0, i);
}
This has SC: O(1)

KoushikChowdhury
Автор

your code doesnt work for "geeksforgeek"

infotainment
Автор

i like your videos, but this solution doesn't work

sophiezhang
Автор

my code is showing TLE for 9000+ characters

paraskumar