Bit manipulation problems in Python
Work with the binary digits of integers in Python, on problems with tests that check your answer at once.
Beginner
Intermediate
- 59. Gray Code SequenceCount through every binary number, flipping only one bit at a time60 XP12 min
- 74. Reverse the BitsRead a 32-bit number in the mirror65 XP10 min
- 325. Total Hamming DistanceCompare every pair of numbers bit by bit and count the differences75 XP14 min
- 327. Two Numbers Without a PartnerEveryone arrived in pairs except two loners: find them75 XP14 min
- 333. Total of Every Subset's XORCombine every possible group of numbers and add up the results80 XP15 min
Advanced
- 140. Decode the XOR ChainRebuild a shuffled list from the XORs of its neighbours130 XP25 min
- 347. Counting in Base Minus TwoWrite any whole number, negatives too, with only 0s and 1s and no minus sign120 XP22 min
- 412. Maximum XOR of Two NumbersFind the two numbers whose bits clash the most150 XP30 min
Expert
- 439. Numbers With Exactly K One BitsUp to a billion billion: how many numbers have exactly k bits switched on?210 XP35 min
- 454. Free the Chinese RingsAn old puzzle of rings on a bar, and the fewest moves that free every ring230 XP45 min
- 455. How Many Different XORsCountless ways to pick numbers, but how many different results do they make?230 XP40 min
Other topics
- Python Basics
- Strings
- Lists
- Dictionaries and sets
- Loops
- Functions
- Math
- Sorting and searching
- Two pointers
- Sliding window
- Stacks and queues
- Recursion and backtracking
- Dynamic programming
- Greedy
- Graphs
- Trees
- Classes
- Iterators and generators
- Parsing
- Simulation
- Python idioms
- Regular expressions
- Codes and ciphers
- Working with data
- Grids and matrices
- Geometry
- Games and puzzles
- Heaps
- Data structures
Or see every challenge, with study plans, today's challenge and duels.