Swiggy online assessment - Check Express
Anonymous User
2058

You are given a single line string of mathematical expression. Your task is to check the syntax for the validity, as defined by the following rules:

  • The expression should start with a number.
  • The expression should end with a number
  • Two numbers are always separated by exactly one operator
  • Two operators cannot occur together

Valid operators are "plus", "minus", "times", "div".
If the input passes your checks print "OK" otherwise "ERR"

For example:
Input: 1 plus 2
Output: OK

Input: 1 2 plus
Output: ERR

Comments (6)