Aditya-K477 / HACTOBERFEST--2024

come and contribute here
12 stars 92 forks source link

Evaluate Postfix Expression #8

Open Rajesh-1234567 opened 1 month ago

Rajesh-1234567 commented 1 month ago

A postfix expression (Reverse Polish notation) is a mathematical notation in which every operator follows all of its operands. For example, the postfix expression for (3 + 4) 5 would be 3 4 + 5 .

You are given a string array tokens representing a postfix expression. Evaluate the expression and return the result.

The valid operators are +, -, *, and /. Each operand can be an integer, and division should truncate towards zero.

Example:

Input: tokens = ["2", "1", "+", "3", "*"] Output: 9

Explanation:

Step 1: Perform 2 + 1 = 3 Step 2: Perform 3 * 3 = 9 Input: tokens = ["4", "13", "5", "/", "+"] Output: 6

Explanation:

Step 1: Perform 13 / 5 = 2 (truncated towards zero) Step 2: Perform 4 + 2 = 6 Constraints: 1 <= tokens.length <= 10^4 tokens[i] is either an integer or an operator: "+", "-", "*", or "/"

Hey @Aditya-K477 ! this is a very good medium-hard problem asked by many tech giants. Please assign this issue to me to solve .

Shikhar8765 commented 1 month ago

@Aditya-K477 please assign me

Samruddhi345A commented 1 month ago

Hi Please assign to me this task

Ruchika2005 commented 1 month ago

Hi , I am Ruchika Patil. Could you please assign this issue to me ?