LeetCode Challenge: Concatenated Binary Solution

🚀 Day 80/100 – LeetCode Daily Challenge 🧠 Problem: Concatenated Binary 📌 Difficulty: Medium Today’s challenge was to concatenate the binary representations of numbers from 1 to n and return the decimal value of the resulting binary string. 💡 Approach: Instead of actually forming the string, I used bit manipulation to simulate the concatenation: For each number i, compute its bit length using floor(log2(i)) + 1. Left shift the current result by that many bits and add i, applying modulo at each step to prevent overflow. This gives an efficient O(n) solution in both time and space. 📊 Result: ✅ 403 / 403 test cases passed ⚡ Runtime: competitive and clean This problem was a great reminder of how bitwise operations can elegantly solve problems that seem string-heavy at first glance. #LeetCode #CodingChallenge #100DaysOfCode #Day80 #Java #BitManipulation #ProblemSolving #Tech #Programming #DailyCoding #DevCommunity #WomenWhoCode #CodeNewbie

  • graphical user interface, text, application

To view or add a comment, sign in

Explore content categories