File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ class queue ():
2
+
3
+ def __init__ (self ):
4
+ self .items = []
5
+
6
+ def push (self , value ):
7
+ self .items .append (value )
8
+ return self .items
9
+
10
+ def pop (self ):
11
+ if len (self .items ) < 1 :
12
+ print ("Queue is empty" )
13
+ else :
14
+ del self .items [0 ]
15
+ return self .items
16
+
17
+ if __name__ == '__main__' :
18
+ q = queue ()
19
+ print (q .push (1 ))
20
+ print (q .push ('haha' ))
21
+ print (q .push (3 ))
22
+ print (q .pop ())
23
+ print (q .pop ())
24
+ print (q .pop ())
25
+ print (q .pop ())
Original file line number Diff line number Diff line change
1
+ class stack ():
2
+
3
+ def __init__ (self ):
4
+ self .items = []
5
+
6
+ def push (self , value ):
7
+ self .items .append (value )
8
+ return self .items
9
+
10
+ def pop (self ):
11
+ if len (self .items ) < 1 :
12
+ print ("Stack is empty" )
13
+ else :
14
+ self .items .pop ()
15
+ return self .items
16
+
17
+ if __name__ == '__main__' :
18
+ st = stack ()
19
+ print (st .push (1 ))
20
+ print (st .push ('haha' ))
21
+ print (st .push (3 ))
22
+ print (st .pop ())
23
+ print (st .pop ())
24
+ print (st .pop ())
25
+ print (st .pop ())
You can’t perform that action at this time.
0 commit comments