โ† Microsoft questions
Codingsimple

Binary String Expression Evaluation

Filed under Microsoft

Free read 2 of 3

Parse the first digit as the initial result.

The question

Evaluate a string of 0s, 1s, and operators (AND, OR, XOR) from left to right without operator precedence.

Constraints

  • Input string length <= 1000
  • Only '0', '1', '&', '|', '^' characters

Examples

Input
1&0|1
Output
1
Why
(1 & 0) = 0, then (0 | 1) = 1.

Approach

  1. Parse the first digit as the initial result.

Tips

  • What they are testing: Tests parsing logic and handling of sequential operations.
  • Common mistake: Assuming standard mathematical precedence (AND before OR).

Related Microsoft questions

Collected from public candidate posts and coding forums. Updated Nov 2026.