Boolean Logic
True/False, AND, OR, NOT, XOR, truth tables, logical equivalences, and De Morgan laws. The foundation of programming conditions.
Lessons
1. Intro
What boolean logic is and why it matters
2. What Is Boolean Logic?
Core concept
3. True and False in Code
Literal values
4. Boolean Variables
Storing true/false
5. The AND Operator
Both must be true
6. AND Truth Table
All combinations
7. The OR Operator
At least one true
8. OR Truth Table
All combinations
9. The NOT Operator
Flips the value
10. NOT Truth Table
Simple flip
11. Quiz: Basic Operators
Knowledge check
12. Combining Operators
Complex expressions
13. Operator Precedence
Order matters
14. The XOR Operator
Exclusive OR
15. XOR Truth Table
Different inputs
16. Short-Circuit Evaluation
Skipping unnecessary work
17. De Morgan's Laws
Negating complex expressions
18. De Morgan's Laws - Example
Concrete application
19. Quiz: De Morgan's Laws
Knowledge check
20. Logical Equivalences
Rewriting expressions
21. Problem - Valid Parentheses
LeetCode 20
22. Valid Parentheses - The Idea
Stack matching
23. Valid Parentheses - Implementation
The code
24. Problem - Power of Two
LeetCode 231
25. Power of Two - The Idea
Single bit set
26. Power of Two - Implementation
The code
27. Quiz: Bitwise and Boolean
Knowledge check
28. Boolean Expressions in Conditionals
If statements
29. Boolean Expressions in Loops
Loop conditions
30. Problem - Find All Numbers Disappeared in an Array
LeetCode 448
31. Find Disappeared - The Idea
In-place marking
32. Find Disappeared - Implementation
The code
33. Problem - Single Number
LeetCode 136
34. Single Number - The Idea
XOR cancellation
35. Single Number - Implementation
The code
36. Quiz: XOR Properties
Knowledge check
37. Boolean Algebra Laws
Transformation rules
38. Absorption and Domination Laws
Simplification rules
39. Common Boolean Logic Mistakes
What to avoid
40. Section Recap
What we learned