Тёмный

Backspace String Compare (LeetCode 844) | Full solution with actual examples | Study Algorithms 

Nikhil Lohia
Подписаться 46 тыс.
Просмотров 6 тыс.
50% 1

Опубликовано:

 

6 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 25   
@TheProblemSolvers38
@TheProblemSolvers38 2 года назад
Your Way of approaching the problem is just amazing.......
@matthewc.9437
@matthewc.9437 Год назад
You are an incredibly talented teacher, thank you so much!
@nikoo28
@nikoo28 Год назад
Wow, thank you!
@parthapardhu3319
@parthapardhu3319 Год назад
wow..next level teaching man..Hope this channel reach higher heights..Thank you 😊
@nikoo28
@nikoo28 Год назад
thanks for your support, if you like to see more such content, consider joining my channel: ru-vid.com/show-UCT-S2ngqEBoYCM5UKuNeELgjoin
@abhishekranjan8356
@abhishekranjan8356 10 дней назад
In question it says to use O(1) time complexity but when you are using StrinBuilder you use O(n) space
@eminentm1655
@eminentm1655 2 года назад
How do you even come up with such. Brilliant Sir
@srikanthmandla8480
@srikanthmandla8480 Месяц назад
Sir, even if we form string in reverse and compare also it will accept , because checking equality no matter of from front or end. if we form string by placing character at 0 index takes much time then placing at end.
@derrickagyemangduah2353
@derrickagyemangduah2353 Год назад
Is there a way to come up with an O(1) space solution?
@dobermanbruce2397
@dobermanbruce2397 Год назад
Love From Rajasthan ❣❣❣❣
@Nishi-Tiwari
@Nishi-Tiwari Год назад
Explanation in such a simpler manner can be only done by you.
@nikoo28
@nikoo28 Год назад
thanks
@harshithgandham6472
@harshithgandham6472 8 месяцев назад
The question clearly mentioned to solve the problem with O(1) space complexity. You solution takes O(n) space. Though it is getting accepted, it is ideally wrong. Can you pls change it to O(1) space.
@nikoo28
@nikoo28 8 месяцев назад
that is the follow up question and it got added recently to LeetCode problem statement. I will put up something in the comments or expand the solution on Github. Thanks for bringing it to my notice 👍
@omkarkhandalkar8869
@omkarkhandalkar8869 2 года назад
thank you sir, sir can create a detailed video on how to calculate time and space complexity
@nikoo28
@nikoo28 2 года назад
Did you see my videos on What is the Time Complexity of an algorithm?
@nikoo28
@nikoo28 2 года назад
There is also one more video, “What is Big O notation?” Have a look at those
@ravimone1
@ravimone1 2 года назад
Hello @Nikhil, Can you create a video on Two pointer approach please, I know there are many videos out there, but your explanation will help me better understanding, please read this comment and help us all.
@nikoo28
@nikoo28 2 года назад
Sure, I will get to it soon. I have some videos on trees in the pipeline first. Will keep on adding the two pointer approach ad-hoc. :)
@ravimone1
@ravimone1 2 года назад
@@nikoo28 you do not sleep?, aree bhai soja,
@funnymoment9164
@funnymoment9164 Год назад
Thanks!
@shwetaj8189
@shwetaj8189 Год назад
We are supposed to use stack in this problem.Can you please explain solution using stack.
@ruchirshrikhande5584
@ruchirshrikhande5584 11 месяцев назад
If you havent got it already, Its similar to the solution given by Nikhil. Whenever we encounter a '#' just pop the top most character and in the end compare the two strings
@lalanabiridi8358
@lalanabiridi8358 10 месяцев назад
.create two new stacks..one for storing alphabest and one for storing hashes....iterate through the string....if u encounter an aplhabet add it to the alphabet stack.....if u encounter a hash add it to the hash stack...now compare the size of two stacks...subtract the sizes...now if the size of hash stack is equal to the length of the alphabet stack...the answer will be an empty string if not...if the alphabet stack is longer than the hash stack....keep popping the elements one by one and as the hash stack would be empty,...the remaining element/elements in the alphabet stack would be returned as a string as the answer...the time complexity would be O(N) approximately if we ignore the O(1) time taken to add and pop the elements...and also we'll only iterate thru the string once....space complexity will be O(N+M) the sizes of newly created stacks
@vishalrane1439
@vishalrane1439 6 месяцев назад
thanks sir
Далее
Backspace String Compare - Leetcode 844 - Python
14:10
LeetCode 844: Backspace String Compare
15:58