Count True Boolean Parenthesizations
Updated
Problem statement
The expression alternates T or F operands with binary operators &, |, or ^. Count the distinct full parenthesizations that evaluate to true, preserving operand and operator order. Each full parenthesization groups every binary operation. Use ordinary Boolean AND, OR, and XOR. Return an exact signed 64-bit count without a modulus.
Function
countTrueWays(expression: String) → longExamples
Example 1
expression = "T^F|F"return = 2Both (T^F)|F and T^(F|F) are true.
Example 2
expression = "T&F|T"return = 2Both possible parenthesizations evaluate to true.
Constraints
- For this exercise, assume between 1 and 19 operands, no whitespace, and no parentheses in the input.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Maximum Equal-Bit Pairs in a SubsequenceAmazon · OA
- Longest Subsequence That Is a SubstringBooking.com · OA
- Count Digit Replacements with No Equal Adjacent DigitsMicrosoft · OAMicrosoft interview questions
- Palindrome CounterGoldman Sachs · OAGoldman Sachs interview questions
- Longest String ChainVisa · OAVisa interview questions
- Minimum-Cost Digit String DecodingSquadStack.ai · OA
- Maximum Redundancy After One Segment FlipBloomberg LP · OABloomberg LP interview questions
- Substrings Without a Target SubsequencePhonePe · OAPhonePe interview questions
- Minimum Edit-Distance String for Each QueryTarget · OA
- Longest Subsequence That Is a SubstringWells Fargo · OAWells Fargo interview questions