Alternating Binary Number Checker

🔥 Day 96 — #100DaysOfLeetCode ✅ Problem: Binary Number with Alternating Bits (Easy) Today’s challenge was to check whether a given integer’s binary representation has alternating bits — meaning no two adjacent bits are the same. 🧠 Approach: Convert number to binary. Check if it contains "11" or "00". If yes → not alternating. Otherwise → valid alternating pattern. ⚡ Example n = 5 → binary = 101 → ✔ alternating ⏱ Complexity Time: O(k) Space: O(1) (k = number of bits) #LeetCode #DSA #CodingChallenge #Python #ProblemSolving

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories