🎩 Number of Ways to Wear Different Hats

Dynamic Programming with Bitmask Visualization

📝 Custom Input

Quick Examples:
Current Input: [[3,4],[4,5],[5]] Expected Output: 1
Normal Hat
Current Hat
Assigned Hat
Unavailable
Hat Preferences by Person
Dynamic Programming State
Step 0 of 0

Step 0: Ready to Start

Use the Next button to step through the dynamic programming algorithm, or Previous to go back.

📊 Algorithm State

Current Hat: None
Current Mask: 0
Total Ways: 0
People Count: 3

📝 Problem Info

People Count: 3

Unique Hats: 4

Algorithm: Bitmask DP

Time Complexity: O(H × 2^N)

Space Complexity: O(2^N)