[CareerCup] 9.11 Parenthesize the Expression 表达式加括号

 

9.11 Given a boolean expression consisting of the symbols 0,1, &, |, and ^, and a desired boolean result value result, implement a function to count the number of ways of parenthesizing the expression such that it evaluates to result.
 EXAMPLE
 Expression: 1^0|0|1
 Desired result: false (0)
 Output: 2 ways. 1^((0|0)|1) and 1^(0|(0|1)).

posted @ 2015-10-01 14:11  Grandyang  阅读(676)  评论(0编辑  收藏  举报
Fork me on GitHub