Stack - Data Structures & Algorithms Tutorial In Python #7

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


Topics
00:00 Introduction
00:14 What is stack?
04:51 Stack in different languages
05:06 Using list as a stack
07:50 Using deque as a stack
11:50 Exercise

#stack #stackdatasstructure #datastructures #algorithms #python

#️⃣ Social Media #️⃣
Рекомендации по теме
Комментарии
Автор

This series gotta be super hit in future

apoorvshrivastava
Автор

Absolutely hilarious bit at the end. I couldn't stop laughing! 😂 :

"If you look at the solution without first solving the problem, it's going to download the covid-19 virus to your computer".

ACivilizedGorilla
Автор

This is literally the best explanation of a stack I have ever seen. I'm someone who dreads data structures and algorithms but after watching this video, I'm actually excited to watch the rest of your DS tutorials. Thank you!

jccrunkreal
Автор

You make some of the easiest to understand explanations for coding stuff that I have come across on the internet. Thank you so much!

anastasiakratschmer
Автор

The way, you explain things, I love it. Most loving part is the exercises.

sourabhbhandary
Автор

Your videos are amazing, you make learning Python much easier! Thankyou :)

vap
Автор

Second exercise item in this tutorial is a brilliant use of push & pops in stack....!
Got the logic for similar set of questions in leetcode. Thank You.

deepaksrinivasan
Автор

Thank you. This playlist have been very helpful. Keep up the great work!

troymendoza
Автор

Thank you. You have a great way of explaining concepts . Codebasics for dummies :)

siddheshrangnekar
Автор

"Watch other data structures videos"
I will for sure.
At first I had curiosity. But now, this channel have my attention.

sukurcf
Автор

Simplified way of explanation, I've been trying to find some resources for python dsa and this is the best. !!

ij
Автор

Data Structures became very interesting with your videos Thank You, sir!!

Sillysmiles
Автор

Thank you very much, for sharing knowledge for free!

muhammadumarsotvoldiev
Автор

thank you dear Sir! Your videos are easy to follow and they are very informative. Take care during outbreak

iliassuvanov
Автор

Read stacks & queues in 12th class, ... but always wondered what its for... browser example really makes sense

ShilpiBhargavaiitb
Автор

It really helps me, Thank you so much!

khanhhoang
Автор

For interview and for oral, this is helpful. Thanks for the videos/

alkeshace
Автор

Thank you. This video help me to understand the subjet.

Kodplace
Автор

Covid 19 virus 😂, i felt like classroom immediately

gautamkartik
Автор

Thanks a lot, It helped me to understand the concept in python. Keep making such good contents. Here is the code of the exercise questions.
solution 1:
from collections import deque
class stack:
def __init__(self):
self.container=deque()
def push(self, val):
self.container.append(val)
def pop(self):
return self.container.pop()
def peek(self):
return self.container[-1]
def is_empty(self):
return len(self.container)==0
def size(self):
return len(self.container)
def reversestring(s):
st=stack()
for i in s:
st.push(i)
revstr=""
while(st.size()!=0):
revstr+=st.pop()

return revstr
print("this function is for reversing a string using stack")
print(reversestring("hello my name is rajnish"))

solution 2:
from collections import deque
class stack:
def __init__(self):
self.container=deque()
def push(self, val):
self.container.append(val)
def pop(self):
return self.container.pop()
def peek(self):
return self.container[-1]
def is_empty(self):
return len(self.container)==0
def size(self):
return len(self.container)
def isbalanced(s):
st=stack()
flag=0
ch=0
for i in s:
if i=="(" or i=="{" or i=="[":
ch+=1
st.push(i)
if (i==")" and ch==0) or (i=="}" and ch==0) or (i=="]" and ch==0):
flag=1
break
if i==")" or i=="}" or i=="]":
x=st.pop()
ch-=1
if x=="(" and i!=")":
flag=1
break
if x=="{" and i!="}":
flag=1
break
if x=="[" and i!="]":
flag=1
break
if flag==1:
return "False"
else:
return "True"
print(isbalanced("({a+b})"))

print(isbalanced("((a+b))"))
print(isbalanced("))"))

rajnishpandey