Brainteaser LeetCode Problems: All 16, With Python Solutions

Every problem in this library that LeetCode tags Brainteaser 16 in total, 14 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 16 problems
  • 2 Easy
  • 13 Medium
  • 1 Hard

Brainteaser problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (2)

#ProblemDifficultyTopics
292Nim GameEasyBrainteaser, Math, Game Theory
1025Divisor GameEasyBrainteaser, Math, Dynamic Programming +1

Medium (13)

#ProblemDifficultyTopics
319Bulb SwitcherMediumBrainteaser, Math
1033Moving Stones Until ConsecutiveMediumBrainteaser, Math
1227Airplane Seat Assignment ProbabilityMediumBrainteaser, Math, Dynamic Programming +1
1503Last Moment Before All Ants Fall Out of a PlankMediumBrainteaser, Array, Simulation
2396Strictly Palindromic NumberMediumBrainteaser, Math, Two Pointers
2419Longest Subarray With Maximum Bitwise ANDMediumBit Manipulation, Brainteaser, Array
2425Bitwise XOR of All PairingsMediumBit Manipulation, Brainteaser, Array
2568Minimum Impossible ORMediumBit Manipulation, Brainteaser, Array
2731Movement of RobotsMediumBrainteaser, Array, Prefix Sum +1
2745Construct the Longest New StringMediumGreedy, Brainteaser, Math +1
2749Minimum Operations to Make the Integer ZeroMediumBit Manipulation, Brainteaser, Enumeration
1908Game of NimPremiumMediumBit Manipulation, Brainteaser, Array +3
2505Bitwise OR of All Subsequence SumsPremiumMediumBit Manipulation, Brainteaser, Array +2

Hard (1)

#ProblemDifficultyTopics
810Chalkboard XOR GameHardBit Manipulation, Brainteaser, Array +2

When the Brainteaser problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.