{"id":"5f4ec710-da26-4748-adbd-3240ec63d1d6","name":"Boolean Parenthesization","description":"1. You are given a boolean expression with symbols T,F, and operators &,|,^ , where\r\n T represents True\r\n F represents False\r\n & represents boolean AND\r\n | represents boolean OR\r\n ^ represents boolean XOR.\r\n2. You have to find the number of ways in which the expression can be parenthesized so that the value of expression evaluates to true.","inputFormat":"Two strings s1 and s2","outputFormat":"Check the sample output and question video.","constraints":"2 <= length of s1 <= 100\r\n1 <= length of s2 <= 99","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String str1, String str2) {\r\n\t\t//write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1, s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"TFT\r\n^&","sampleOutput":"2\r\n","questionVideo":"https://www.youtube.com/embed/JbRsM2X2_pg?end=66","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"367ca4bf-5cd1-4098-8b62-56c037388c8f","name":"Boolean Parenthesization","slug":"boolean-parenthesization","type":1}],"next":{"id":"793c61fd-ef04-46f5-b834-16abfb3cb031","name":"BOOLEAN PARENTHESIZATION MCQ","type":0,"slug":"boolean-parenthesization-mcq"},"prev":{"id":"c2cf3145-9134-4b7f-9536-90c44172a753","name":"Matrix Chain Multiplication","type":3,"slug":"matrix-chain-multiplication"}}}

Boolean Parenthesization

1. You are given a boolean expression with symbols T,F, and operators &,|,^ , where T represents True F represents False & represents boolean AND | represents boolean OR ^ represents boolean XOR. 2. You have to find the number of ways in which the expression can be parenthesized so that the value of expression evaluates to true.

{"id":"5f4ec710-da26-4748-adbd-3240ec63d1d6","name":"Boolean Parenthesization","description":"1. You are given a boolean expression with symbols T,F, and operators &,|,^ , where\r\n T represents True\r\n F represents False\r\n & represents boolean AND\r\n | represents boolean OR\r\n ^ represents boolean XOR.\r\n2. You have to find the number of ways in which the expression can be parenthesized so that the value of expression evaluates to true.","inputFormat":"Two strings s1 and s2","outputFormat":"Check the sample output and question video.","constraints":"2 <= length of s1 <= 100\r\n1 <= length of s2 <= 99","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String str1, String str2) {\r\n\t\t//write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1, s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"TFT\r\n^&","sampleOutput":"2\r\n","questionVideo":"https://www.youtube.com/embed/JbRsM2X2_pg?end=66","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"367ca4bf-5cd1-4098-8b62-56c037388c8f","name":"Boolean Parenthesization","slug":"boolean-parenthesization","type":1}],"next":{"id":"793c61fd-ef04-46f5-b834-16abfb3cb031","name":"BOOLEAN PARENTHESIZATION MCQ","type":0,"slug":"boolean-parenthesization-mcq"},"prev":{"id":"c2cf3145-9134-4b7f-9536-90c44172a753","name":"Matrix Chain Multiplication","type":3,"slug":"matrix-chain-multiplication"}}}
plane

Editor


Loading...

Boolean Parenthesization

easy

1. You are given a boolean expression with symbols T,F, and operators &,|,^ , where T represents True F represents False & represents boolean AND | represents boolean OR ^ represents boolean XOR. 2. You have to find the number of ways in which the expression can be parenthesized so that the value of expression evaluates to true.

Constraints

2 <= length of s1 <= 100 1 <= length of s2 <= 99

Format

Input

Two strings s1 and s2

Output

Check the sample output and question video.

Example

Sample Input

TFT ^&

Sample Output

2

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode