🚀 Day 71 of #100DaysOfCode – Pattern Problems 🧩 Problem of the Day: ✅ Bridge Pattern Today, I practiced the Bridge pattern, which is a good exercise to strengthen conditional logic inside nested loops. 💡 Approach (Space + Star Control): The bridge pattern visually looks like two vertical pillars connected by a horizontal bridge on the top. 🔍 Core Logic: First row: Print continuous stars to form the bridge (top connection) Middle rows: Print a star at the beginning and end Print spaces in between Last row (optional based on pattern variation): Similar to the first row or open bottom 📌 The key idea is to print stars only at fixed positions and spaces everywhere else. 🧮 Time Complexity: O(N × M) (N = rows, M = columns) 💾 Space Complexity: O(1) ✨ Lesson of the Day (Approach-Focused): Pattern problems sharpen attention to row–column positioning. Conditional checks are more important than loops in such patterns. Visualizing the output before coding makes implementation easier. #100DaysOfCode #DSA #PatternProblems #Java #LogicBuilding #CodingJourney #Consistency #Practice #NestedLoops
Day 71: Mastering Bridge Pattern with Conditional Logic
More Relevant Posts
-
🚀 Day 5/30 – Understanding Stack-Based Validation Today I worked on validating balanced parentheses in a string — a classic problem that tests understanding of stacks and order of operations. The challenge was to ensure that every opening bracket has a corresponding closing bracket in the correct order. Instead of relying on pattern matching, I implemented a stack-based approach, which naturally fits this type of problem. 💡 Approach Traverse the string character by character Push opening brackets onto the stack When encountering a closing bracket, check whether it matches the most recent opening bracket If at any point the structure breaks, return false This approach ensures: O(n) time complexity O(n) space complexity (in worst case) 📊 Result ✅ Accepted (All test cases passed) ⚡ Efficient runtime performance 📚 Key Takeaway This problem reinforced an important concept: Stacks are extremely powerful when dealing with nested structures, syntax validation, and expression parsing. Small problems like this build strong fundamentals for larger system-level logic. Day 5 complete. Consistency continues. #Day5 #30DaysOfCode #LeetCode #Java #Stacks #Algorithms #DataStructures #ProblemSolving #SoftwareEngineering #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 50 of #100DaysOfCode 🎯 (Halfway there! 🔥) Today’s challenge was an array + dynamic programming twist problem — 📊 LeetCode: Maximum Product Subarray 📌 Problem Summary Given an integer array, find the contiguous subarray (containing at least one number) that has the largest product. At first glance, it looks similar to maximum subarray sum… but the presence of negative numbers changes everything ⚠️ 🧠 My Approach: Tracking Max & Min Products The key insight 👇 A negative number can turn the smallest product into the largest. So instead of tracking only the maximum, I tracked: ✅ max product ending at current index ✅ min product ending at current index At each step: Compute new max using (current, max*current, min*current) Compute new min similarly Update the global result This keeps everything in one pass 🚀 ⚙️ Complexity Analysis ⏱ Time: O(n) 💾 Space: O(1) Efficient and clean ✨ 🔥 Key Learning Negative numbers can flip the problem logic Some DP problems don’t need arrays — just smart state tracking Always think in terms of states, not just values ✅ Solution accepted with strong runtime performance Another powerful array pattern mastered 💪 Onward from Day 50 — the grind continues 🚀🔥 #100DaysOfCode #LeetCode #Java #DynamicProgramming #Arrays #ProblemSolving #CodingJourney #DSA
To view or add a comment, sign in
-
-
🚀 Day 47 | LeetCode Medium 🟩 Set Matrix Zeroes Today’s problem focused on matrix traversal + space trade-offs, and it was a great reminder that clarity beats complexity. 🧠 Core Idea If any cell in the matrix is 0, then its entire row and column must be set to 0. Instead of modifying the matrix immediately (which can break logic), I used an auxiliary tracking approach. 🛠️ Approach Used Traverse the matrix once Mark affected rows and columns using helper arrays Traverse again and update cells based on these markers This avoids incorrect cascading zeros and keeps the logic clean. ⚡ Why this works Separation of detection and update No accidental overwrites Easy to reason and debug ⏱️ Complexity Time: O(m × n) Space: O(m + n) 🔗 Code on GitHub 👉 https://lnkd.in/g-zxCztf 💡 Key Learning In matrix problems, when you update is just as important as what you update. 🔥 Consistency > Speed Another step forward in my daily DSA journey 🚀 #LeetCode #LeetCodeDailyProblem #SetMatrixZeroes #DSA #Java #Arrays #Matrix #ProblemSolving #CodingJourney #100DaysOfCode #TechCommunity
To view or add a comment, sign in
-
-
🚀 Day 15 – LeetCode 209 | Minimum Size Subarray Sum | Sliding Window Mastery Most people brute-force this problem with O(n²) nested loops and call it a day. That’s lazy thinking. If your first instinct isn’t O(n) with sliding window, you’re not thinking like a serious engineer yet. Problem: Given positive integers, find the smallest length subarray whose sum ≥ target. Naive: Check every subarray → slow → useless for large inputs. Correct mindset: Two pointers + running sum. Move right → expand window When sum ≥ target → move left → shrink window Track minimum length Time: O(n) Space: O(1) This is not just a problem — it trains: • Window optimization • Two-pointer thinking • Real interview patterns • How to kill brute force early If you still default to nested loops, fix that habit now. Top engineers think in patterns, not force. Consistency check: 15 days straight of DSA. No skips. No excuses. Code + explanation done. On to Day 16. #LeetCode #Day15 #DSA #Java #SlidingWindow #Algorithms #CodingInterview #SoftwareEngineer #ProblemSolving #100DaysOfCode #TechGrowth
To view or add a comment, sign in
-
While solving 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝟯𝟰𝟱𝟯 – 𝗦𝗲𝗽𝗮𝗿𝗮𝘁𝗲 𝗦𝗾𝘂𝗮𝗿𝗲𝘀 𝗜, what stood out to me was that this problem isn’t really about geometry — it’s about choosing the right dimension to reason on. At first, dealing with multiple squares feels complex because of overlapping areas and 2D space. But the key shift in thinking is realizing that you don’t need to reason in two dimensions simultaneously. By projecting the problem onto a single axis and reasoning about how area accumulates, the solution becomes much more manageable. Instead of tracking shapes, the focus moves to how area changes as we move along a line. Once area contribution is modeled correctly, separating the squares becomes a matter of finding the point where accumulated area satisfies the required condition. What I liked about this problem is how it reinforces a common engineering lesson: complexity often comes from how we model the problem, not from the problem itself. The moment the model is simplified, the implementation naturally follows. #Java #ProblemSolving #AlgorithmicThinking #SystemThinking #SoftwareEngineering #CleanAbstractions
To view or add a comment, sign in
-
🚀 Day 57 of #100DaysOfCode Today’s problem was a clean and classic two-pointer exercise — 🔁 LeetCode 344: Reverse String Simple on the surface, but a great reminder of in-place algorithms and pointer manipulation. 📌 Problem Summary You’re given a character array s. Your task is to reverse the array in-place, using O(1) extra space. 🧠 Approach Used: Two Pointers ✔️ Initialize: left = 0 right = s.length - 1 ✔️ Swap characters while left < right, then move pointers inward. This ensures: No extra memory Linear traversal Clean and readable logic ⚙️ Complexity Analysis ⏱ Time Complexity: O(n) 💾 Space Complexity: O(1) (in-place) ✔️ 477 / 477 test cases passed 🚀 Runtime: 0 ms (Beats 100%) 🔥 Key Learning Even the simplest problems reinforce core fundamentals: Two-pointer technique In-place operations Space optimization Mastering basics = dominating harder problems later 💪 Onward to Day 58 🚀 #100DaysOfCode #LeetCode #ReverseString #TwoPointers #Java #DSA #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 29/100 of my #LeetCodeChallenge! ✅ Today's problem tested logical thinking through spatial constraints. Given horizontal and vertical bars on a grid, the goal was to find the largest possible square opening that can remain unobstructed. 🔍 Approach Breakdown: Sort & Sequence Detection – First, sorted both horizontal and vertical bar arrays. Consecutive Length Calculation – Tracked the longest consecutive sequence in each set of bars using a linear scan. Square Formation Logic – Realized the largest square side is limited by the smaller of the two maximum consecutive bar gaps, plus one. Elegant Optimization – Achieved O(n log n + m log m) time complexity with minimal space usage, beating runtime and memory benchmarks. 💡 Key Insight: The problem cleverly reduced a 2D layout challenge into a 1D consecutive sequence problem. This reflects how many real-world spatial and matrix problems can be simplified by breaking them down into independent dimensions. 🚀 Why It Matters: Problems like this strengthen skills in: Dimensional decomposition Sequence analysis and state tracking Geometric reasoning in grids and meshes Translating constraints into clean, efficient code With each day, I'm sharpening my ability to see patterns, optimize solutions, and articulate the thought process behind the code. #Day29 #LeetCode #Java #CodingChallenge #100DaysOfCode #ProblemSolving #Algorithms #DataStructures #GridProblems #SpatialReasoning #Programming #SoftwareEngineering #Developer #CodeNewbie #TechJourney #AlgorithmicThinking #CleanCode #Optimization #TechSkills #CareerGrowth
To view or add a comment, sign in
-
-
Day 29/100 of my #LeetCodeChallenge! ✅ Today's problem tested logical thinking through spatial constraints. Given horizontal and vertical bars on a grid, the goal was to find the largest possible square opening that can remain unobstructed. 🔍 Approach Breakdown: Sort & Sequence Detection – First, sorted both horizontal and vertical bar arrays. Consecutive Length Calculation – Tracked the longest consecutive sequence in each set of bars using a linear scan. Square Formation Logic – Realized the largest square side is limited by the smaller of the two maximum consecutive bar gaps, plus one. Elegant Optimization – Achieved O(n log n + m log m) time complexity with minimal space usage, beating runtime and memory benchmarks. 💡 Key Insight: The problem cleverly reduced a 2D layout challenge into a 1D consecutive sequence problem. This reflects how many real-world spatial and matrix problems can be simplified by breaking them down into independent dimensions. 🚀 Why It Matters: Problems like this strengthen skills in: Dimensional decomposition Sequence analysis and state tracking Geometric reasoning in grids and meshes Translating constraints into clean, efficient code With each day, I'm sharpening my ability to see patterns, optimize solutions, and articulate the thought process behind the code. #Day29 #LeetCode #Java #CodingChallenge #100DaysOfCode #ProblemSolving #Algorithms #DataStructures #GridProblems #SpatialReasoning #Programming #SoftwareEngineering #Developer #CodeNewbie #TechJourney #AlgorithmicThinking #CleanCode #Optimization #TechSkills #CareerGrowth
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟯𝟲/𝟭𝟬𝟬 | 𝗠𝗲𝗿𝗴𝗲 𝗧𝘄𝗼 𝗦𝗼𝗿𝘁𝗲𝗱 𝗟𝗶𝘀𝘁𝘀 Day 36 ✅ — Recursion over iteration. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟮𝟭: Merge Two Sorted Lists (Easy) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Merge two sorted linked lists. Instead of the iterative dummy node approach, I used 𝗿𝗲𝗰𝘂𝗿𝘀𝗶𝗼𝗻. Compare the heads. Attach the smaller one, then recursively merge the rest. Base case: if one list is empty, return the other. Elegant. Three lines of logic. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 Base cases: if l1 is null, return l2 (and vice versa) 👉 Compare l1.val and l2.val 👉 Attach smaller node and recurse with remaining lists Time: O(n + m), Space: O(n + m) for recursion stack 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Seven linked list problems, and recursion just made this one cleaner than iteration. Sometimes the simplest code is the most powerful. 𝗖𝗼𝗱𝗲:🔗 https://lnkd.in/g4f4_B69 𝗗𝗮𝘆 𝟯𝟲/𝟭𝟬𝟬 ✅ | 𝟲𝟰 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #LinkedList #Recursion #DataStructures #CodingInterview #SoftwareEngineer #Java #Algorithms #Programming
To view or add a comment, sign in
-
Day 17 – LeetCode 1004 | Sliding Window Done Right (O(n) Solution) Day 17 of solving problems consistently. Solved LeetCode 1004 – Max Consecutive Ones III. Problem: Given a binary array, you can flip at most k zeros. Return the maximum number of consecutive 1s possible. Brute force checks every subarray → O(n²) → wasteful. A better approach is Sliding Window + Two Pointers → O(n). Core logic: • Expand window with right pointer • Count zeros • If zeros exceed k → move left pointer • Track max window length This problem is a good reminder that: Constraints usually hint the optimal technique. If you see “subarray + max/min + linear time” → think Sliding Window first. Consistency builds skill. 17 days. No breaks. Code + explanation in the video 👇 #LeetCode #DSA #Algorithms #SlidingWindow #TwoPointers #Java #ProblemSolving #CodingInterview #SoftwareDeveloper #100DaysOfCode #TechJourney
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