Count Binary Substrings with Run-Length Encoding Logic

🚀 Day 63/100 – #LeetCodeChallenge 📌 Problem: Count Binary Substrings Today’s problem was all about spotting patterns in binary strings — and it turned out to be a fun exercise in run-length encoding logic! 🧠 🔍 Approach: Instead of storing counts separately, I used a simple linear scan to keep track of consecutive identical characters (strk) and the length of the previous run (prev). Whenever a run ends, we update prev and reset strk. Then, if the current streak is ≤ the previous one, it means we’ve found a valid substring — and we increment the result. 📈 ⚡ Result: ✅ Runtime: 10 ms – beats 87.50% 🚀 💾 Memory: 46.44 MB – beats 56.68% Feeling good about the balance between time and space efficiency here! Every day is a step closer to mastering problem-solving patterns. 💪 🔗 Takeaway: Sometimes the most elegant solutions come from simple observation — no need for complex data structures when a single pass and a few variables do the trick! #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #TechJourney #DevCommunity #StringManipulation #Algorithms #CodeNewbie #SoftwareEngineering #WomenInTech #CodingLife #InterviewPrep #DataStructures #DailyCoding

  • graphical user interface

To view or add a comment, sign in

Explore content categories