🚀 Day 3 of my 30-Day Coding Challenge with Educative.io Today’s problem looked simple but had some fun twists. The task: given a binary string, find the number of steps to reduce it to 1 by repeatedly 1)dividing by 2 if even 2)adding 1 if odd. At first, I tried converting the binary to a number and then looping. Lesson learned — in JavaScript, large binary strings (length > 53 bits) overflow the Number limit. My approach worked for small inputs but failed for long ones. After debugging, I discovered a smarter pattern: 1)Work directly on the binary string from right to left. 2)Use a carry variable to simulate “add 1” operations. 3)Count operations based on whether the current bit + carry is odd or even. This avoids conversion and runs in O(n) time for strings up to 500 characters! Here’s what I took away from this challenge: Always think about data type limits (JS Number ≠ unlimited integer). Sometimes the best solution is bit-level simulation instead of numeric math. Debugging is just as valuable as solving. #JavaScript #CodingChallenge #Educative #LearningInPublic #DSA #ProblemSolving #SoftwareEngineering
"Day 3 of 30-Day Coding Challenge: Binary String Reduction"
More Relevant Posts
-
🚀 [Day 10/30] Coding Challenge Journey with Educative 💡 Problem: Group Anagrams Today’s challenge was an interesting one — grouping words that are anagrams of each other. This problem pushed me to think deeply about string manipulation and hashing techniques. At first, I tried a frequency map approach — creating a character map for each string and comparing it with others. Though it worked, it wasn’t efficient (≈ O(n × k²) 😅). Then I optimized it by sorting each string and using the sorted value as a key in a hash map — grouping all strings with the same key together. This brought down the complexity to O(n × k log k) and made the logic much cleaner. Finally, I explored another variation — building a frequency-based signature for each string (like "a1b1c1") and using that as the key. This further improved the complexity to O(n × k) and avoided unnecessary sorting 🎯 🔍 Key Learnings: Choosing the right key representation is crucial for efficiency. Hash maps are powerful tools for grouping problems. Optimization is all about rethinking your data structure, not just your logic. ✨ Small win — seeing the same problem solved in 3 different ways reminded me that there’s always room to improve your first approach 💪 #30DaysOfCode #Day9 #CodingChallenge #DSA #Educative #ProblemSolving #JavaScript #HashMap #Anagrams #Optimization #KeepCoding #LearningJourney
To view or add a comment, sign in
-
Day 25 of #100DaysOfCode 🚀 Today’s focus was on sharpening fundamentals with a classic string problem — simple on the surface, yet excellent for refining logical clarity and attention to detail. 🧩 Problem — Consonants and Vowels Check (GfG) The task: Count vowels and consonants in a string and compare them. What made it interesting? Even a basic comparison can fail if you don’t handle spaces, symbols, or case variations. Filtering only valid alphabets before counting was crucial for achieving accurate results. Key Java takeaway: Clarity in input constraints and precise condition handling matter more than complexity. 💡 Key Learning String problems are not just about characters—they’re about discipline in logic: ✔ Clean input ✔ Handle edge cases ✔ Keep code simple and readable Improving these fundamentals builds the precision needed for advanced DSA topics. #100DaysOfCode #Day25 #CodingJourney #JavaDeveloper #DSA #StringProblems #GeeksforGeeks #CodingPractice #LearningEveryday #ProgrammerLife #TechJourney #ProblemSolving #CodingCommunity
To view or add a comment, sign in
-
-
Day 34 | Cohort 2.0 Journey🔁✨ Today’s session was all about controlling the flow of logic in JavaScript by Harsh Vandana Sharma from Sheryians Coding School learning how decisions and repetitions are handled inside programs. 🧠 Key Concepts Covered: 🔹 if, else if, and else : Basic conditional branching 🔹 Truthy & Falsy Values : Understanding values like 0, "", undefined, NaN, null, and even document.all 🔹 Ternary Operator : Shorter way to write conditions 🔹 Switch Case : Cleaner multi-condition handling 🔹 Loops : Starting with for loop to repeat actions efficiently These are the real backbone of logic writing, helping us make our code smart, dynamic, and interactive ⚡ #Day34 #JavaScript #Conditionals #Loops #FrontendDeveloper #Cohort2 #LearningJourney #SheryiansCodingSchool
To view or add a comment, sign in
-
🚀 [Day 12/30] Coding Challenge Journey with @Educative.io 💻 💡 Problem: Count Subarrays With Fixed Bounds Today’s challenge really tested my understanding of subarray patterns and sliding window logic. The task was to count all subarrays where the minimum and maximum values are exactly equal to given bounds — minK and maxK. At first, my approach was brute force — I generated all possible subarrays, calculated the min and max for each, and increased the count if they matched. It worked, but with a painful O(n² + n) time complexity 😅 Then came the optimization breakthrough 💡 — I introduced three variables: badIndex → to mark positions where elements go out of range minIndex and maxIndex → to store the latest positions of valid min and max For each element, if it stayed within bounds, I could efficiently calculate how many valid subarrays ended at that index by using: count += Math.max(0, Math.min(minIndex, maxIndex) - badIndex) This reduced the complexity to O(n) and turned an expensive brute force into a clean, efficient linear pass ⚡ 🔍 Key Learnings: Identifying invalid states early (like badIndex) saves massive computation. Most subarray problems can be optimized using index tracking instead of recalculating repeatedly. Optimization isn’t about writing less code — it’s about thinking one step deeper 🧠 ✨ Small win — seeing how a few well-chosen variables can simplify a seemingly complex logic! #30DaysOfCode #Day12 #CodingChallenge #DSA #Educative #ProblemSolving #JavaScript #SlidingWindow #Optimization #KeepCoding #LearningJourney #Subarrays
To view or add a comment, sign in
-
How I'm Building My DSA Foundation: A Step-by-Step Roadmap A few weeks back, I sat down and made a simple plan to get good at Data Structures & Algorithms once and for all; good, here, meaning actually understand how things work under the hood, not only for cracking interviews. Here's what my roadmap looks like Step 1: Choose ONE Language & Learn the Basics ➡️ Java, C++ ,Python ,C Emphasize syntax, loops, functions, and OOP. Let's not jump between languages - depth > breadth. Step 2: Understand Time & Space Complexities Before solving problems, learn to measure efficiency. Big-O Cheat Sheet https://lnkd.in/dCjiDwTk Step 3: Deep Dive into DSA Concepts Here's my hitlist: Searching & Sorting Divide & Conquer Hashing Computer Algorithms-Greedy Algorithms Recursion & Backtracking Trees & Graphs Dynamic Programming DSA Guide- GeeksforGeeks https://lnkd.in/dCZdNv5b Step 4: Practice Religiously Platforms I use daily: LeetCode https://leetcode.com/ HackerRank https://lnkd.in/d2Y3yWcw CodeWars https://www.codewar.com/ CodeChef https://www.codechef.com/ Codeforces https://lnkd.in/d5R9PKnA Step 5: Compete & Track Growth Join coding contests they're the best reality checks. LeetCode Weekly https://lnkd.in/dnzCt72H CodeChef Contests https://lnkd.in/d7GEAUvs TopCoder https://www.topcoder.com/ ⚡My personal rule: “1 problem a day keeps imposter syndrome away.” Stay consistent. Don’t compare. Keep building. #DSA #CodingJourney #100DaysOfCode #TechLearning #ProblemSolving #SoftwareEngineering #CodeNewbie #Developer
To view or add a comment, sign in
-
-
🚀 [Day 15/30] Coding Challenge Journey with @Educative.io 💻 💡 Problem: Similar String Groups Today’s problem was all about identifying relationships between strings and grouping them based on their “similarity.” Two strings are considered similar if they differ in exactly two character positions — meaning you can swap those characters to transform one into the other. My intuition started with this core idea: 👉 If two strings differ by exactly two positions, they belong to the same group. To solve this, I approached the problem like a graph traversal challenge: 1️⃣ Consider each string as a node in a graph. 2️⃣ Create an edge between two nodes if the strings differ by exactly two characters. 3️⃣ Use DFS to explore all connected strings that form a similarity group. 4️⃣ Maintain a visited array to ensure each string is processed once. So for each unvisited string, I triggered a DFS call. That DFS marked all strings connected to it (all strings that were similar by 2-character difference). This naturally formed groups of similar strings — each connected component counted as one group. This problem beautifully reinforced how string similarity + graph connectivity can come together to form a clean and efficient solution 🧠✨ 🔍 Key Learnings: Many string problems hide an underlying graph structure — discovering it is half the solution. DFS is extremely powerful for grouping, clustering, and connectivity problems. A simple rule (differ by 2 characters) can create surprisingly complex group relationships. ✨ Small win — once I mapped the problem to graph traversal instead of brute-force comparisons, everything became much more intuitive! #30DaysOfCode #Day15 #CodingChallenge #Educative #DSA #GraphTheory #DFS #JavaScript #ProblemSolving #StringAlgorithms #LearningJourney #KeepCoding
To view or add a comment, sign in
-
When I started learning to code, I thought success meant mastering every language out there. So I jumped from C++ to Python to JavaScript — and ended up knowing a little bit of everything, but not enough of anything. It took me months (and a lot of frustration) to realize — the goal isn’t to learn every tool, it’s to learn how to think. Because the truth is — - Companies don’t hire you for syntax, they hire you for problem-solving. - The best developers aren’t the ones who know most languages, but the ones who can debug calmly. - You don’t need to rush — one well-built project speaks louder than 10 unfinished ones. - Tutorials will teach you “how,” but only building teaches you “why.” - Growth doesn’t happen when you switch stacks — it happens when you stick long enough to master one. If I could go back, I’d spend less time chasing trends and more time understanding fundamentals. If you’re in your early coding phase, this is your reminder — depth beats breadth. Every single time. #codingjourney #softwareengineering #learnprogramming #techgrowth #careerlessons
To view or add a comment, sign in
-
-
The Power of Small, Daily Progress in Coding When I first started learning to code, I believed that in order to get better, I would need to work for hours every day. To be honest, though, that strategy never succeeded. On some days, I felt exhausted, disoriented, or just angry. Then I decided to do something easy: Just code a little bit every day. 20 to 30 minutes, or even an hour is fine. And it changed everything. Some days I corrected a lot of mistakes. Some days I just watched tutorials. Some days I just practiced, built a lot of programs, and failed at many of them. But by learning to code daily, things started getting easier. I began to understand logic better, remember syntax naturally, and actually started enjoying the process. The truth is, small steps every day may not seem exciting, but over time they can become something exciting. Don't worry about being flawless if you're learning to code. Simply keep going, one line of code at a time. You'll be shocked at how far you can go with this consistency. #CodingJourney #Consistency #DeveloperLife #Python #WebDevelopment #KeepLearning
To view or add a comment, sign in
-
-
Day 31 of #100DaysOfCode – Building Logic with Conditions and Loops in JavaScript Today’s session focused on strengthening core programming logic using conditional statements and loops. Key Learnings: Understood how if, else if, and else conditions control program flow. Explored looping structures to execute repetitive tasks efficiently. Learned how combining these concepts helps in building real-world logic and problem-solving patterns. Takeaway: Mastering loops and conditions is the foundation for writing efficient, dynamic, and logical code in JavaScript. Grateful to Harsh Vandana Sharma from Sheryians Coding School and Sheryians Coding School Community for guiding us through today’s session with clear explanations and practical logic-building examples. #100DaysOfCode #JavaScript #WebDevelopment #CodingJourney #Frontend #ProgrammingLogic
To view or add a comment, sign in
-
-
The Art of Efficient Problem-Solving. “Programs must be written for people to read, and only incidentally for machines to execute.” — Harold Abelson Efficiency in JavaScript isn’t just about speed—it’s about clarity and logic. Explore the beauty of efficient coding with LearnMing. https://www.rfr.bz/lb52f75 #CodingQuotes #JSWisdom #ProblemSolving #LearnMing
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development