Adding Binary Strings with Carry-Based Approach

🔹 Day 31: Add Binary (LeetCode #67) 📌 Problem Statement: Given two binary strings a and b, return their sum as a binary string. ✅ My Approach: Simulated binary addition manually using a carry-based approach. Started from the end of both strings, added corresponding bits along with the carry, appended the remainder (sum % 2) to the result, and updated the carry (sum / 2). Finally, reversed the result string to get the correct binary sum. 📊 Complexity: Time Complexity: O(max(n, m)) Space Complexity: O(max(n, m)) ⚡ Submission Stats: Runtime: 1 ms (Beats 99.71%) Memory: 42.45 MB 💡 Reflection: This problem strengthened my understanding of bitwise addition and string manipulation — a perfect mix of logic and implementation precision! ⚙️ #LeetCode #Java #String #Binary #100DaysOfCode #Day31

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories