forked from neetcode-gh/lesson-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.cs
More file actions
42 lines (32 loc) · 645 Bytes
/
code.cs
File metadata and controls
42 lines (32 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections;
public class Stack {
// Old Code:
// ArrayList stack = new();
// Corrected Code:
ArrayList stack = new ArrayList();
public Stack() {}
public void Push(int n)
{
stack.Add(n);
}
public int Pop()
{
if (Size() > 0)
{
int ele = (int)stack[stack.Count-1];
stack.RemoveAt(stack.Count-1);
return ele;
}
return -1;
}
public int Size()
{
return stack.Count;
}
}
// Add this to allow compilation and execution
class Program {
public static void Main(string[] args) {
}
}