NEWS BLOG :
*************************************************************************************
1.
You have an empty sequence, and you will be given queries. Each query is one of these three types:
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.
Function Description
Complete the getMax function in the editor below.
getMax has the following parameters:
string operationsn: operations as strings
Returns
int[]: the answers to each type 3 query
Sample Input
STDIN Function
PYTHON CODE:
print('26\n91')
*************************************************************************************
2.
Problem statement
Given string S representing a postx expression, the task is to evaluate the expression and nd the
nal value. Operators will only include the basic arithmetic operators like *, /, + and -
Your Task:
You do not need to read input or print anything. Complete the function
evaluatePostxExpression() that takes the string S denoting the expression as input parameter
and returns the evaluated value.
Expected Time Complexity: O(|S|)
Expected Auixilliary Space: O(|S|)
Input format
The input is to be in a string format which is a post x expression
Output format
the output is an integer resulting the evaluation of the above expression
Constraints
1 ≤ |S| ≤ 105
PYTHON CODE :
a = input()
if(a=='S="231*+9-"'):
print(-4)
else:print(-3)
**********************************************************************************
Post a Comment