We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. HourRank 30
  3. Jerry's Expression

Jerry's Expression

Problem
Submissions
Leaderboard
Discussions
Editorial

This problem revolves around the Polish notation.

  • Polish notation is the way to write parenthesis-free expressions. Its distinguishing feature is that it places operators to the left of their operands.
  • expression ::= number | (operator expression expression)
  • operator ::= | | | | …
  • For example: "" is "".

You are given a Polish notation expression. Operators can be only and . Each number in expression is replaced with . You have to replace each with positive integer number, so that value of expression was . Also, you have to make the biggest number in expression as small as possible.

Input Format

The only line contains string with expression (string will contain only '?', '+' and '-').

Constraints

  • string length .

Output Format

Return an integer array, number should be the number for '?' in the string. If there are many solutions print any.

Sample Input 0

-?-??

Sample Output 0

1
2
1

Explanation 0

- 1 - 2 1   is   1-(2-1) = 0

Author

nikasvanidze

Difficulty

Medium

Max Score

45

Submitted By

215

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download all test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature