I know many people will say that they are not here to do solve programming for me or may cite the "Open Letter to Students" and belive me I am asking because the discussion forum on HackerRank is dead for me
So here the question :
1 x -Push the element x into the stack.
2 -Delete the element present at the top of the stack.
3 -Print the maximum element in the stack
Ouput the largest number in the Stack
Sample Input:
10
1 97
2
1 20
2
1 26
1 20
2
3
1 91
3
Sample Output:
26
91
My Solution:
data = []
for _ in range(int(input())):
ins = input().split()
if ins[0] == '1':
data.append(int(ins[1]))
elif ins[0] == '2':
data.pop()
else:
print(max(data))
It gets slow on working with input size of 1000 elements or so
Whats the problem ??