Adds solution for LeetCode Daily Challenge on 20th October 2024,Sunday in Java.
The approach uses a stack to process boolean expressions. As we traverse the expression, we skip commas and parentheses, pushing booleans (t, f) and operators (&, |, !) onto the stack. When encountering a closing parenthesis, we evaluate the subexpression by popping values, tracking whether we find t or f. Based on the operator, we push the result back onto the stack: for !, we push the opposite; for &, we push f if any f is found, otherwise t; for |, we push t if any t is found, otherwise f. The final result will be the top value in the stack.
π Issue Reference:
Fixes issue: # (Mention the issue number this PR solves)
π Checklist:
Please ensure the following before submitting your PR:
[ βοΈ ] I have placed my solution in the correct folder (solutions/dayXX/).
[ βοΈ ] My code follows clean coding practices and is efficient.
[ βοΈ ] I have added comments in my code to explain the approach.
[ βοΈ ] I have updated the README.md for the specific day with a brief explanation of my solution.
[ βοΈ ] I have tested the solution on LeetCode and it works correctly.
π What does this PR do?
t
,f
) and operators (&
,|
,!
) onto the stack. When encountering a closing parenthesis, we evaluate the subexpression by popping values, tracking whether we findt
orf
. Based on the operator, we push the result back onto the stack: for!
, we push the opposite; for&
, we pushf
if anyf
is found, otherwiset
; for|
, we pusht
if anyt
is found, otherwisef
. The final result will be the top value in the stack.π Issue Reference:
Fixes issue: # (Mention the issue number this PR solves)
π Checklist:
Please ensure the following before submitting your PR:
solutions/dayXX/
).README.md
for the specific day with a brief explanation of my solution.π§ Solution Details:
π Additional Notes (if any):