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)).
本文转自博客园Grandyang的博客,原文链接:表达式加括号[CareerCup] 9.11 Parenthesize the Expression ,如需转载请自行联系原博主。