1106. Parsing A Boolean Expression Hard

@problem@discussion
#String#Stack#Recursion



1/**
2 * [1106] Parsing A Boolean Expression
3 *
4 * Return the result of evaluating a given boolean expression, represented as a string.
5 * An expression can either be:
6 * 
7 * 	"t", evaluating to True;
8 * 	"f", evaluating to False;
9 * 	"!(expr)", evaluating to the logical NOT of the inner expression expr;
10 * 	"&(expr1,expr2,...)", evaluating to the logical AND of 2 or more inner expressions expr1, expr2, ...;
11 * 	"|(expr1,expr2,...)", evaluating to the logical OR of 2 or more inner expressions expr1, expr2, ...
12 * 
13 *  
14 * Example 1:
15 * 
16 * Input: expression = "!(f)"
17 * Output: true
18 * 
19 * Example 2:
20 * 
21 * Input: expression = "|(f,t)"
22 * Output: true
23 * 
24 * Example 3:
25 * 
26 * Input: expression = "&(t,f)"
27 * Output: false
28 * 
29 *  
30 * Constraints:
31 * 
32 * 	1 <= expression.length <= 2 * 10^4
33 * 	expression[i] consists of characters in {'(', ')', '&amp;', '|', '!', 't', 'f', ','}.
34 * 	expression is a valid expression representing a boolean, as given in the description.
35 * 
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/parsing-a-boolean-expression/
40// discuss: https://leetcode.com/problems/parsing-a-boolean-expression/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45    pub fn parse_bool_expr(expression: String) -> bool {
46        false
47    }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54    use super::*;
55
56    #[test]
57    fn test_1106() {
58    }
59}
60


Back
© 2025 bowen.ge All Rights Reserved.