Given an expression, **A**, with operands and operators **(OR , AND , XOR)**, in how many ways can you evaluate the expression to true, by grouping in different ways?

Operands are only **true** and **false**.

Return the number of ways to evaluate the expression modulo **10 ^{3} + 3**.

**Input Format:**

```
The first and the only argument of input will contain a string, A.
The string A, may contain these characters:
'|' will represent or operator
'&' will represent and operator
'^' will represent xor operator
'T' will represent true operand
'F' will false
```

**Output:**

```
Return an integer, representing the number of ways to evaluate the string.
```

**Constraints:**

```
1 <= length(A) <= 150
```

**Example:**

```
Input 1:
A = "T|F"
Output 1:
1
Explanation 1:
The only way to evaluate the expression is:
=> (T|F) = T
Input 2:
A = "T^T^F"
Output 2:
0
Explanation 2:
There is no way to evaluate A to a true statement.
```

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**Evaluate Expression To True**

to access hints and editorial solutions for

Loading...