short concise and easy to understand. Your way of teaching is perfect. Please keep it up
@smithshelke20365 жыл бұрын
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
@deepakvm14753 жыл бұрын
nice
@yusenpeng Жыл бұрын
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! :)
@koikoi91 Жыл бұрын
I would like to see your solution if you dont mind please
@krishnavar7219 Жыл бұрын
the the way you programmed this question it is genius...
@strider_935 жыл бұрын
How do you handle when char is repeated odd no of times like if string is abbbac
@adhishmalviya24084 жыл бұрын
"abac" should be the output for this I know what you're thinking output should have been "c" according to you but this problem is diffenret
@dharmaputra73945 жыл бұрын
Request tutorial graph like a MST, djikstra shortest path
@044_karan94 жыл бұрын
what was that noise in the starting of the video !!
@sadmanabedin12034 жыл бұрын
I thought the sound came from my side, your comment just assured me that I am safe here 😂
@theyashbansal3 жыл бұрын
That clap at the beginning blew my ear off 😅
@canobiggs5 жыл бұрын
You're my hero man!
@biswaranjanbarik40522 жыл бұрын
U r doing a very very great job thanx that I have found u in youtube. I love your videos.. Love from India..❤💌
@dalindu75724 жыл бұрын
why using a char[] as stack instead of using STACK ADT?
@simonkaranja38112 жыл бұрын
wondering too!! I did this easily using a Stack class Solution { public String removeDuplicates(String s) { Stack stack = new Stack(); StringBuilder sb = new StringBuilder(); for(int i=0;i
@karanjindal18604 жыл бұрын
"aaaaaaaa" this doesn't work
@CodeSuccessChronicle3 жыл бұрын
Brother you didn’t write a 0 assignment in case there’s a duplicate how can stack change then ....
@unknownman14 жыл бұрын
7:25 how does string from 0,2 returns c,a. Instead of 0,2 it should be 0,1?
@gaurav91pandey3 жыл бұрын
0 is inclusive, 2 is exclusive
@theweekday81582 жыл бұрын
@@gaurav91pandey actually the 2 in (stack, 0, 2 ) is the offset and not the exclusive index. 0 is the starting index and 2 here tells about the length from index 0 till which it will copy from stack into the new string.
@canobiggs5 жыл бұрын
Such good stuff in every video
@guyfromgalaxy2 жыл бұрын
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! :) )
@koikoi91 Жыл бұрын
I would like to see your solution if you dont mind please
@ketansharma6955 Жыл бұрын
I have never used stack with indices, can someone share me some problems, which use the same. Thanks.
@samvid742 жыл бұрын
It does not work with aaab result is ab should be b
@yassinesalimi21555 жыл бұрын
very helpful. Thanks a lot !
@satvikshukla5962 жыл бұрын
Very very helpful. Thank you!!
@KoushikChowdhury20168 ай бұрын
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)
@abhijeetmishra43004 жыл бұрын
wrong solution bro
@paraskumar6933 жыл бұрын
my code is showing TLE for 9000+ characters
@simrankak70453 жыл бұрын
You are Amazing dude thankyou
@sophiezhang65164 жыл бұрын
i like your videos, but this solution doesn't work
@varunsadhu90605 жыл бұрын
It doesn't work for TC aabbccccbapq
@mohdzebalam87063 жыл бұрын
space is o(1)
@chodingninjas74155 жыл бұрын
u are the best
@infotainment71234 жыл бұрын
your code doesnt work for "geeksforgeek"
@gauravagarwal65653 жыл бұрын
*With no extra space* --------------------------------- StringBuilder sb = new StringBuilder(s); int i = 0; while(i0) i --; } else{ i++; } } return sb.toString();
@nishantvaishla57523 жыл бұрын
thanks bro
@harshdeepsinghful3 жыл бұрын
Without extra space class Solution { public String removeDuplicates(String S) { //String s="abbaca"; for(int i=0;i
@piyushmathpal42443 жыл бұрын
why this line two times ? s=s.substring(0,i)+s.substring(i+1, s.length()); Also, Can you please confirm if the solution is working for the input "abbaca"?
@harshitsharma40634 жыл бұрын
acaaabssscp this doesn't work, I believe u thought of only two consecutive are adjacent!! Btw np , thanks keep posting
@HarishAmarnath4 жыл бұрын
seriously you can figure out without o(n) spaces ? , you can iterate the string with 2 a and b pointers . stop the first pointer a when a and a-1 index is equal , then paste a+1th index item at a-1 , also make b=a+1; a=a-2;..... keep going until list ends.