• For input `['10','6','9','3','+','-11','*','/','*','17','+','5','+']`, it seems the expected answer from the system is `22`. However, I think the correct answer should be `21`? The reason is that during the evaluation `6 / -132` would be approximately `-0.45` so that the final answer is `21.55`. Then `int(21.55)` will give us the answer as `21`.

Of course one can argue that the answer should be rounded to the nearest integer. However, if that is the case, input `["4", "13", "5", "/", "+"]` should yield answer as `7` (rounded from `6.6`) instead of `6` as the question page.

• Integer division simply drops the decimal, not rounds, so 6/-132 is 0.

``````10,6,9,3
+
10,6,12
10,6,12,-11
*
10,6,-132
/
10,0
*
0
0,17
+
17
17,5
+
22``````

• If you don't mind, could you show your line of thought for 21? Even if you went with -0.45, the next step is *10, so you'd end up with 18.5, not 21.55, before the truncation.

• Except integer division in Python actually rounds 6 / -132 to -1 because it does floor division (always round down to nearest int). So careful Pythonistas!

This SO answer provides a nice explanation:

http://stackoverflow.com/questions/5535206/python-negative-integer-division-surprising-result

• I would say

``````
6 / -132 = -1
```
```

So the expected answer should be 12.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.