💻 Day 22/100 ✅ Today’s problem was “Final Value of Variable After Performing Operations.” A simple logic-based question that turned into a great debugging lesson! 🔍 Initially, my code kept returning the wrong output — I later realized it was because of a return statement placed inside the loop, which made the function stop after the first operation. Once I understood that, fixing it became easy. ✨ Key takeaway: Even small placement mistakes can change the entire flow of your program. Coding isn’t just about writing logic — it’s about understanding execution flow step by step. Every bug is a teacher in disguise! 💪 #Day22 #100DaysOfCode #LeetCode #Java #ProblemSolving #Debugging #LearningByDoing
Debugging Lesson from a Simple Logic Question
More Relevant Posts
-
Day 26 of #100DaysOfCode 🚀 Today's problem was all about balance — literally. 🔹 LeetCode 1941 — Check if All Characters Have Equal Number of Occurrences The task: Verify whether every character in a string appears the same number of times. At first glance, it looks simple — but it's a great exercise in clean logic, frequency counting, and edge-case handling. 🧠 Approach (Java): Use an array of size 26 to store character frequencies. Track the first non-zero frequency. Compare all other non-zero counts with it. If any mismatch occurs → return false. Otherwise, the string is perfectly balanced. A small problem, but a powerful reminder that clarity > complexity. Efficient logic and readable code always scale better in the long run. 💡 Key Takeaway Mastering these bite-sized logic checks builds strong intuition for: ✔ string manipulation ✔ hashing concepts ✔ pattern consistency ✔ frequency-based problem solving These fundamentals become the building blocks for bigger DSA challenges. #100DaysOfCode #Day26 #LeetCode #DSA #JavaDeveloper #CodingJourney #ProblemSolving #Programming #Strings #Hashing #LearningEveryday #TechJourney
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟐𝟏 𝐨𝐟 #50DaysOfDSA 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐋𝐢𝐧𝐤 : https://lnkd.in/gzNm43Xx 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 𝐋𝐢𝐧𝐤 : https://lnkd.in/gAXsPq4Q Today’s challenge was all about counting substrings efficiently — without generating them one by one. The problem? Given a binary string, find the number of substrings that contain only ‘1’s, modulo 1e9+7. 𝐊𝐞𝐲 𝐈𝐧𝐬𝐢𝐠𝐡𝐭: Instead of checking all substrings, simply count consecutive 1s. For every continuous segment of k ones, the number of valid substrings is: 𝐤 * (𝐤 + 𝟏) / 𝟐 But we optimize further by counting while we iterate. 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: -> Maintain a running count of consecutive 1s -> Add that to the total whenever a 1 appears -> Reset when a 0 appears -> Handle large numbers using modulo 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝐧) 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝟏) #leetcode #dsa #java #coding #problemsolving #programming #learningeveryday #devcommunity #softwareengineering #100daysofcode #girlswhocode #problem solving
To view or add a comment, sign in
-
-
📌 Day 18/100 - Valid Palindrome (LeetCode 125) 🔹 Problem: Determine whether a string reads the same forward and backward, ignoring case and non-alphanumeric characters. 🔹 Approach: Implemented a two-pointer technique. Skipped all non-alphanumeric characters. Compared characters from both ends in lowercase. Returned true if all matched, otherwise false. 🔹 Key Learning: Two-pointer method keeps logic clean and efficient. Character handling is key when data isn’t uniform. Time complexity: O(n), Space complexity: O(1). Sometimes, solving elegantly is better than solving fast. ✨ #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingJourney
To view or add a comment, sign in
-
-
#75DaysChallenge 🔥 Day 26 of #75DaysChallenge 🔥 Today’s topic: Dynamic Programming (0/1 Knapsack – “Ones and Zeroes”) 💻 🧩 Problem: Ones and Zeroes (Leetcode #474) You’re given an array of binary strings strs and two integers m and n. Find the largest subset such that the total number of 0s ≤ m and 1s ≤ n. 💭 Intuition: Think of this like a Knapsack problem — Each string is an item. It has two weights: number of 0’s and 1’s. You can include it only if there’s enough capacity (m zeros, n ones). 🎯 Goal → maximize how many strings you can pick! ⚙️ Approach: 1️⃣ Count the number of 0’s and 1’s in each string. 2️⃣ Use a 2D DP array dp[m+1][n+1], where dp[i][j] = max subset size using ≤ i zeros and ≤ j ones. 3️⃣ Update dp backward for each string to avoid reusing it (classic knapsack trick). #DynamicProgramming #Leetcode #Java #CodingChallenge #100DaysOfCode #ProblemSolving #WomenWhoCode #75DaysChallenge #DSA #LearningJourney
To view or add a comment, sign in
-
-
🚀 Day 140 of #150DaysOfCode on LeetCode Solved: 1526. Minimum Number of Increments on Subarrays to Form a Target Array Language: Java The task was to determine the minimum number of subarray increment operations needed to build the target array from all zeros. 🔹 Intuition: Every time the current element is greater than the previous one, it means we need that many new operations to reach the next level. Decreases don’t add extra work since earlier increments already cover them. 🔹 Approach: Start with the first element’s value as the initial count. For each subsequent element, if it’s larger than the previous one, add the difference. The sum of all such differences gives the minimum number of operations required. 🔹 Complexity: Time: O(n) Space: O(1) #LeetCode #150DaysOfCode #Java #CodingChallenge #ProblemSolving #Greedy #Arrays #DSA #TechLearning #Programmer #WomenInTech #CodeJourney #DynamicProgramming
To view or add a comment, sign in
-
-
💥 Stop solving 500 random Leetcode questions! If you can master these 7 patterns, you can crack any DSA problem. Most developers don’t need more problems they need clarity on the patterns behind them. 🚀 Here’s what I wish I knew earlier: If you understand 1. Sliding Window 2. Two Pointers 3. Binary Search 4. Recursion 5. Dynamic Programming 6. Greedy 7. Backtracking ...then every new problem will start to look familiar. 💡 Save this post 🔖 and start with one pattern a week. Your consistency will matter more than your question count. 👇 Comment which pattern took you the longest to understand! #DSA #Java #BackendDevelopment #Leetcode #ProgrammersLife
To view or add a comment, sign in
-
Day-77 of #100CodeOfCodeChallenge 🚀 🚀 LeetCode Daily Challenge — Problem #3217: Delete Nodes From Linked List Present in Array Today’s problem focused on linked lists — specifically removing all nodes whose values exist in a given array LeetCode. 🧠 Key Concepts Practiced: Linked List traversal HashSet for O(1) lookup Pointer manipulation for clean deletions Efficient memory-safe node removal ✨ Approach: Store the target values in a HashSet Use a dummy node to handle head deletions smoothly Traverse and skip nodes whose values are in the set 💡 Result: ✔️ 100% test cases passed ⚡ Runtime: 20ms — Beats 86.51% 📦 Memory optimized Every challenge adds one more brick to the coding foundation 🧱 Happy to keep learning, improving, and sharing progress! Let’s grow together! 🙌💻 #leetcode #dsa #linkedlist #codingjourney #java #consistency
To view or add a comment, sign in
-
-
📘 Day 07/10 of Linked List Series: Delete a Node at the End 🧠 Algorithm (Step-by-Step Explanation) Let’s see how we can delete the last node from a linked list 👇 1️⃣ Check if the list is empty If head == null, there’s nothing to delete → return null. 2️⃣ Check if there’s only one node If head.next == null, deleting that node makes the list empty → return null. 3️⃣ Traverse the list Start from the head and move until you reach the second last node (the node before the last one). 4️⃣ Unlink the last node Make the next of the second last node null — this removes the last node from the list. 5️⃣ Return the updated head The list now has one node deleted from the end. 🪄 Simple Example If your list is → 10 -> 20 -> 30 -> null After deleting the last node → 10 -> 20 -> null 💡 Keep learning, keep building! follow my brand 👉#CodeWithLakkojuEswaraSai #CodeWithLakkojuEswaraSai_LinkedList #DSA #LinkedList #JavaDeveloper #CodingCommunity #100DaysOfCode #LearnDSA #Programming #Java #CodingJourney #TechWithPurpose #LeetCode #CodeNewbie #DevelopersCommunity
To view or add a comment, sign in
-
-
🚀 Day 68 of #100DaysOfChallenge Today's problem: 3461. Check If Digits Are Equal in String After Operations I (LeetCode - Easy) This problem was a fun blend of pattern observation and modular arithmetic — a great reminder that even simple-looking questions can strengthen your logical flow and coding discipline on LeetCode. 🧩 Problem Overview: We’re given a string of digits, and in each step, we repeatedly calculate the sum of every pair of consecutive digits modulo 10, until only two digits remain. Finally, we check whether those two digits are equal. 💡 My Approach: Used a straightforward simulation approach — repeatedly computing new strings of digits using modular arithmetic until only two digits were left. It’s simple, direct, and performs efficiently for short strings. ⚙️ Language: Java ⚡ Runtime: 8 ms (Beats 72.03%) 💾 Memory: 44.67 MB (Beats 69.77%) ✅ Result: Accepted — 706 / 706 test cases passed Every daily problem adds another layer of precision and confidence. Consistency isn’t just about coding every day — it’s about learning something new with every attempt. 🌱 On to the next challenge 💪 #100DaysOfCode #LeetCode #ProblemSolving #Java #CodingChallenge #Programming #DeveloperJourney #LearningEveryday #TechMindset #Consistency
To view or add a comment, sign in
-
-
🚀 Day 129/160 – Total Decoding Messages | Dynamic Programming Today’s challenge was about decoding numeric messages into alphabets (like 1→A, 2→B...26→Z). Used a DP approach to count all valid decoding ways efficiently. 🧠 Key takeaway: Dynamic Programming shines when a problem’s state depends on previous results — here, each position depends on the previous one and the one before it. #100DaysOfCode #GeeksforGeeks #160DaysOfDSA #DynamicProgramming #ProblemSolving #Java #CodingJourney #LearnByDoing
To view or add a comment, sign in
-
Explore related topics
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