𝐃𝐚𝐲 𝟏𝟗/𝟏𝟎𝟎 𝐨𝐟 𝐃𝐒𝐀 ✨ #100daysofCode Day 19 was all about seeing patterns clearly before coding. I worked on two different problems, but both taught the same lesson: logic > lines of code. 🔹 Problem 1: Pascal’s Triangle What I learned: Every row starts and ends with 1 Middle elements are formed by adding the two elements just above Pattern clarity makes implementation straightforward Key insight: Once the pattern is understood, the code almost writes itself. 🔹 Problem 2: Line Visibility (Who can see whom) What I learned: A person can see only shorter people Visibility stops at the first person of equal or greater height Stack logic should be used to find blockers, not blindly count Key insight: This problem taught me the importance of thinking in terms of constraints, not just data structures. 🔹 Common takeaway from both problems Don’t jump into coding Understand rules, blockers, and boundaries One clear insight can fix multiple wrong approaches Onwards to Day 20 🚀 #100DaysOfCode #Day19 #DSA #PascalTriangle #Stack #ProblemSolving #LearningByDoing #Consistency
Day 19 of 100 Days of Code: Logic Over Lines of Code
More Relevant Posts
-
🎉🔥 #Day13 of my #100DaysCodingChallenge 🔥🎉 What began as a habit is now turning into a strong foundation of logical thinking and clean coding practices. Today marks Day 13, with a focus on array traversal, optimization, and observation-based problem solving 💪 🔹 Problem 1: Replace Elements with Greatest Element on Right Side (LeetCode Submission: https://lnkd.in/dnBr_wEY ) This problem required replacing every element in the array with the greatest element among the elements to its right. 💡 Approach: ➡️ Traversed the array from right to left ➡️ Maintained the maximum element seen so far ➡️ Replaced each element with the current maximum ➡️ Updated the maximum during traversal ⏱️ Time Complexity: O(N) 💾 Space Complexity: O(1) 🎯 Key Takeaway: Right-to-left traversal helps eliminate unnecessary comparisons and allows in-place optimization. 🔹 Problem 2: Max Consecutive Ones (LeetCode Submission: https://lnkd.in/dVjAiXUc ) A fundamental array problem focused on counting the maximum number of consecutive 1s in a binary array. 💡 Approach: ➡️ Iterated through the array once ➡️ Maintained a counter for current consecutive 1s ➡️ Reset the counter when a 0 was encountered ➡️ Tracked the maximum count throughout traversal ⏱️ Time Complexity: O(N) 💾 Space Complexity: O(1) 🎯 Key Takeaway: Simple counters combined with single-pass traversal can solve many array problems efficiently. 🌟 Final Reflection 13 days in. Stronger logic. Cleaner solutions. Small consistent efforts are building long-term confidence 🚀 🔖 Hashtags #100DaysOfCode #Day13 #DSA #Java #LeetCode #Arrays #ProblemSolving #InterviewPreparation #CodingPractice #LearningInPublic #StudentDeveloper #CodingJourney #Consistency
To view or add a comment, sign in
-
One of the best habits I’m currently building is writing pseudocode before writing real code. It forces me to slow down, think clearly, and design the logic first instead of jumping straight into syntax and getting stuck. If you’re new to programming, pseudocode is one of the simplest tools to reduce overwhelm and build real problem-solving skills. Clear thinking first. Clean code later. #OctoPrep #PythonDeveloper #DataScience #DataAnalysis
To view or add a comment, sign in
-
32).😁 🚀 LeetCode #219 – Contains Duplicate II | Arrays | Hashing | C++ Solved LeetCode Problem 219, which focuses on index-based duplicate detection using hashing. 🔍 Problem Overview Given an integer array nums and an integer k, determine whether there exist two distinct indices i and j such that: nums[i] == nums[j] |i - j| ≤ k If such indices exist, return true; otherwise, return false. 📌 Example Input: nums = [1,2,3,1], k = 3 Output: true It uses a **sliding window** approach combined with an **unordered set** to efficiently track elements. As the loop iterates through the array, the set stores only the last `k` elements seen so far. If the current index `i` becomes greater than `k`, the element that lies just outside the window (`nums[i - k - 1]`) is removed from the set to maintain the window size. Before inserting the current element `nums[i]`, the code checks whether it already exists in the set; if it does, that means the same value has appeared within the last `k` indices, so the function immediately returns `true`. -> If no such duplicate is found throughout the loop, the function returns `false`. !!!!!!!!! This approach runs in **O(n)** time and uses **O(k)** extra space, making it efficient for large inputs !!!!!!!!!! ⚙️ Complexity Analysis ⏱ Time Complexity: O(n) 💾 Space Complexity: O(n) 📌 Language: C++ 📌 Platform: LeetCode #LeetCode #CPlusPlus #DSA #Arrays #Hashing #ProblemSolving #CodingPractice #CompetitiveProgramming #SoftwareEngineering #ComputerScience #CSStudents #BCA #BCAStudents #InterviewPreparation #DailyCoding #LearningToCode #DeveloperJourney #TechJourney #Consistency #CodingLife
To view or add a comment, sign in
-
-
🔥 LeetCode Problem Breakdown: Longest Consecutive Ones III 🔥 Find the longest subarray containing 1s after flipping at most k zeros. Steps: Uses two pointers to mark a sliding window: i (left) and j (right). Keeps track of:count — the current window size, m — the number of zeros flipped so far. Moves j forward to expand the window. If zeros flipped exceed k, moves i forward to shrink the window. Updates the max window size (maxCount) during iteration. This algo works but could be improved... ❌ Manual window size tracking (count). Sometimes count is incremented or decremented manually, which can cause confusion or subtle bugs. Why not just use j - i + 1 for window size? ❌ Shrinking the window is complicated. When the number of zero flips m reaches k and a zero appears next, the code moves i forward and adjusts counters. This logic requires careful attention and can be hard to follow. A Cleaner Algo to Solve the Problem Here’s a simpler approach that’s easier to understand and maintain: Use two pointers (left and right) for the window. Keep track of how many zeros are inside it with zeroCount. When zeros become more than k, move left forward while updating zeroCount. Calculate window size directly as right - left + 1. Track the maximum window size while moving through the array once. Why is this better? ✔️ No manual count management — window size is simple subtraction. ✔️ Logic is separated — zeroCount monitors zeros, shrinking only happens when necessary. ✔️ Easier to debug — variables clearly show their purpose. Final Thoughts 🧠 Coding is not just about making solutions that work — it’s also about writing solutions others (and future you!) can easily read and maintain. Start simple → Build solid foundations → Optimize readability and correctness. 💬 If this helps, or if a simpler explanation or example is wanted, feel free to ask! #ProgrammingBasics #CodingEducation #SlidingWindow #LeetCode #CleanCode #AlgorithmsForBeginners
To view or add a comment, sign in
-
All these LLMs that now generate coding solutions in seconds were trained on Stack Overflow - the holy scripture of developers. Ironically, in doing so, they’re slowly putting the very platform that taught them everything out of business.
To view or add a comment, sign in
-
Day 34 of Coding Practice 🚀 Today’s learning reminded me that small logic improvements make a big difference in problem solving. 🔹 Practiced string manipulation problems in Java 🔹 Focused on understanding conditions, loops, and edge cases 🔹 Learned how to think step-by-step instead of jumping to the final answer 💡 Key takeaway: Writing code is easy, but understanding why it works is what actually builds confidence. Every day of practice is helping me improve my logic, clarity, and debugging skills. Consistency really is the key 🔑 On to Day 35 💪 #Day34 #CodingPractice #Java #ProblemSolving #LearningJourney #Consistency #DeveloperLife my code ===== class Solution { static ArrayList<Integer> removeDuplicates(int[] arr) { ArrayList<Integer> n=new ArrayList<>(); for(int i=0;i<arr.length;i++) { if(!n.contains(arr[i])) { n.add(arr[i]); } } return n; } public static void main(String hjk[]) { removeDuplicates(new int[]{1,2,3,2,1,5,9}); } }
To view or add a comment, sign in
-
-
This set of index cards comes up a lot in my videos about the AI-augmented coding pattern language. It's a trick I learned from Kent Beck and his "Smalltalk Best Practice Patterns". When I repeat an interaction with what Kent calls "the genie", I make a card to remind me that this is something that applies in multiple situations. When I'm stuck talking to the genie, I take out the cards and flick through to find something relevant to the current problem. These cards—all 33 of them, currently—form the core of Patterns in AI-Augmented Software Development: https://lnkd.in/eNggkc64
To view or add a comment, sign in
-
-
People underestimate this LeetCode problem. That’s why they miss the real lesson. Today I worked on LeetCode 1221 — Split a String in Balanced Strings. At first glance, it looks like a basic counting task. But it quietly tests something more important. The challenge isn’t splitting the string. It’s tracking balance correctly over time. One wrong assumption about when to increment or reset the counter, and the logic breaks — even though the code looks fine. What clicked for me was this: You don’t need complex data structures here. You need discipline in state tracking. Once you focus on maintaining balance instead of reacting to characters, the solution becomes straightforward. Simple problem. Strong lesson. Day 19 / 45 — Linear DSA Challenge. Honest question: Do you find state-tracking problems easier than pointer-based ones? #DSA #LeetCode #Strings #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
🚀Back to the Grind Headline: Rebuilding the Habit — From Sliding Windows to Recursion Trees It feels good to be back on the LeetCode rhythm after a short break. Today was all about sharpening my skills in String & Bit Manipulation, with a deep dive into Recursive Backtracking: ✅ Count Binary Substrings (Grouping logic) ✅ Longest Substring Without Repeating Characters (Sliding Window) ✅ Alternating Bits (Bit properties) ✅ Subsets / Power Set (Recursive "Include/Exclude" pattern) 💡 The Big Takeaway Many "hard-looking" problems start to crumble once you identify the underlying pattern. Whether it’s realizing a sliding window can handle dynamic ranges or seeing recursion as a decision tree, the logic is usually there. The real challenge? Boundary handling. Most of my "Wrong Answer" submissions today weren't because of a flawed core strategy, but because of a missed base case or a ±1 error. It's a humble reminder that in software, the details aren't just details; they are the product. Slow progress > no progress 🚀 #LeetCode #DSA #Recursion #ProblemSolving #CodingPractice #KeepLearning #ComputerScience #SoftwareEngineering
To view or add a comment, sign in
-
-
33). 😆 🚀 LeetCode #643 – Maximum Average Subarray I | Sliding Window | C++ Solved LeetCode Problem 643, which focuses on finding the maximum average of a fixed-length subarray using the sliding window technique. 🔍 Problem Overview Given an integer array nums and an integer k, the task is to find the maximum average value of any contiguous subarray of length k. 📌 Example Input: nums = [1,12,-5,-6,50,3], k = 4 Output: 12.75 First, it calculates the sum of the first `k` elements and stores it in `sum`, which also initializes `maxs` since this is the first possible window. Then, the loop continues from index `k` to the end of the array, sliding the window one step at a time: it adds the new element entering the window and removes the element leaving the window (`nums[i - k]`). After each shift, `maxs` is updated to store the maximum window sum seen so far. Finally, the function returns `maxs / k`, which gives the maximum average. -> This approach runs in **O(n)** time and uses **O(1)** extra space, making it efficient and optimal. ⚙️ Complexity Analysis ⏱ Time Complexity: O(n) 💾 Space Complexity: O(1) 📌 Language: C++ 📌 Platform: LeetCode #LeetCode #CPlusPlus #DSA #SlidingWindow #Arrays #TwoPointers #ProblemSolving #CodingPractice #CompetitiveProgramming #SoftwareEngineering #ComputerScience #CSStudents #BCA #MCA #BCAStudents #InterviewPreparation #DailyCoding #LearningToCode #DeveloperJourney #TechJourney #Consistency #CodingLife
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