💡 (7th Nov 2025) Today I Learned: Patterns — Advanced (Part 1) After mastering basic star and shape patterns, today I moved into advanced pattern problems — where logic meets precision. Here’s what I learned and practiced 👇 1️⃣ Hollow Rectangle Pattern — Learning how to print borders while leaving the center blank using nested loops. 2️⃣ Dry Run: Hollow Rectangle Pattern — Understanding each iteration of i and j to visualize how the pattern is formed. 3️⃣ Inverted & Rotated Half Pyramid — Controlling spaces and stars to achieve mirrored symmetry. 4️⃣ Inverted Half Pyramid with Numbers — Introducing numerical logic within pattern loops. 5️⃣ Floyd’s Triangle Pattern — A beautiful number pattern that fills a triangle incrementally. 💬 Key Takeaway: Pattern problems aren’t just about visuals — they sharpen loop control, logic sequencing, and dry-run analysis. Every pattern teaches precision, patience, and problem-solving — three key skills for any developer. #CodingJourney #Patterns #Java #dsa #Programming #DeveloperGrowth #ApnaCollege #LearningInPublic #LogicBuilding
Learned Advanced Patterns in Java: Hollow Rectangle, Half Pyramid, and Floyd's Triangle
More Relevant Posts
-
🧩 Day 64 of #100DaysOfCode 🧩 🔹 Problem: Remove All Adjacent Duplicates in String – LeetCode ✨ Approach: Used a stack-based approach to efficiently remove adjacent duplicates. For each character, if it matches the stack’s top element, pop it — otherwise, push it. A simple yet powerful way to process strings in O(n) time while maintaining clean logic. ⚡ 📊 Complexity Analysis: Time Complexity: O(n) — each character is processed once Space Complexity: O(n) — for the stack and output string ✅ Runtime: 23 ms (Beats 54.52%) ✅ Memory: 45.26 MB (Beats 85.43%) 🔑 Key Insight: Sometimes, solving problems isn’t about brute force — it’s about using the right data structure to make every step count. 💡 #LeetCode #100DaysOfCode #ProblemSolving #DSA #Stack #StringManipulation #CleanCode #CodingChallenge #AlgorithmDesign #LogicBuilding #CodeJourney #Programming
To view or add a comment, sign in
-
-
Spiral Matrix — Thinking in Layers In this problem, the goal was to print all elements of a 2D matrix in spiral order. What seemed like a simple traversal at first actually required structured thinking. Here’s how I approached it: * Broke the matrix into four boundaries — top, bottom, left, and right. * Traversed one boundary at a time in a fixed direction (right, down, left, up). * After completing each layer, I shrank the boundaries and repeated the process until all elements were visited. What I learned: * Strengthened my understanding of 2D array traversal. * Learned how to control loops and boundaries efficiently. * Improved my ability to break big problems into smaller logical steps — an essential skill for scalable coding and system design. Each DSA problem feels like a mini system design — the clearer your logic, the cleaner your code. #Java #DSA #ProblemSolving #CodingJourney #CleanCode #LogicBuilding #LeetCode #Programming #TechCareers #ProductBasedCompanies
To view or add a comment, sign in
-
-
🚀 Day 143 of #150DaysOfCode on LeetCode Problem: 2257. Count Unguarded Cells in the Grid Today’s challenge was a fun simulation and grid traversal problem! 🧩 In this task, we’re given a grid with guards and walls, and we must determine how many cells remain unguarded. Each guard can monitor cells in four directions — up, down, left, and right — until they’re blocked by a wall or another guard. This problem beautifully blends matrix manipulation, directional traversal, and boundary checks — concepts that often appear in real-world simulation tasks and game logic design. 🔍 Key Takeaways: Efficient grid representation simplifies complex visual problems. Direction-based iteration is a powerful technique for 2D traversal. Managing boundary conditions is essential in simulation-based coding problems. 🧠 Concepts Practiced: Grid traversal | Simulation | Matrix manipulation | Directional logic #LeetCode #150DaysOfCode #Day143 #CodingChallenge #LearnByDoing #ProblemSolving #Java #DSA #GridTraversal #Simulation #CodeEveryday
To view or add a comment, sign in
-
-
🚀 LeetCode POTD — 2536. Increment Submatrices by One 🎯 Difficulty: Medium | Topics: 2D Difference Array, Prefix Sums, Matrix Manipulation 🔗 Solution Link: https://lnkd.in/gpjg6t5w Today’s #LeetCode Problem of the Day was a classic 2D difference array question — simple once you recognize the pattern, but extremely efficient compared to brute-force updates. We’re given an n × n zero matrix and multiple queries, where each query asks us to increment every element in a submatrix by 1. Updating each cell one-by-one would be too slow, so difference-array logic makes the solution clean and optimal. 🧠 My Approach: For each query [x, y, a, b], instead of updating the entire submatrix, update only the start and end boundaries using difference marks: matrix[i][y] += 1; if (b + 1 < n) matrix[i][b + 1] -= 1; Loop from row x to a and apply these boundary updates. After processing all queries, run a prefix sum row-wise to build the final matrix. This reduces the complexity drastically and leverages the power of prefix operations. 📈 Complexity: Time: O(n² + q × submatrix_height) Space: O(n²) 💡 Takeaway: Difference arrays (1D or 2D) are among the most elegant techniques to convert repeated updates into boundary operations — a pattern that appears often in competitive programming and system-level problems. #LeetCode #ProblemOfTheDay #DSA #Matrix #PrefixSum #DifferenceArray #CodingChallenge #Programming #SoftwareEngineering #CodingJourney #100DaysOfCode #TechCommunity
To view or add a comment, sign in
-
-
🔥 Day 108 of My DSA Challenge – Merge Sorted Array 🔷 Problem : 88. Merge Sorted Array 🔷 Goal : Merge two sorted arrays into one sorted array in-place inside nums1. The tricky part? nums1 already has extra space at the end — and we need to fill it without using extra arrays. 🔷 Key Insight : Use the two-pointer technique starting from the end — this avoids overwriting values in nums1. Pointer p1 → end of valid elements in nums1 Pointer p2 → end of nums2 Pointer idx → last index in final merged array Place the largest element first by comparing from the end. 🔷 Approach : 1️⃣ Start from the last elements of both arrays 2️⃣ Compare and place the greater one at the end 3️⃣ Move pointers backwards 4️⃣ If nums2 still has elements, copy them This gives us O(m + n) time and O(1) extra space ✅ Sometimes the most elegant solutions are not about building new structures but smartly reusing what you already have. Two-pointer technique continues to be a powerful tool in array problems 💪 #Day108 #100DaysOfCode #LeetCode #DSA #Java #TwoPointers #Arrays #CodingChallenge #Algorithm #InPlaceAlgorithms #ProblemSolving #Programming #SoftwareEngineering #TechJourney #DeveloperJourney #CodeEveryday #LearnDSA #GrowthMindset #EngineerMindset #LogicBuilding
To view or add a comment, sign in
-
-
📌 Day 153 of Coding - Maximum Frequency of an Element After Operations I (LeetCode - Medium) 🎯 Goal: Given an integer array nums, an integer range k, and a number of operations, determine the maximum possible frequency of any number after performing up to numOperations modifications - where each operation can change a number by at most k. 💡Approach & Debugging: Found the maximum value in the array and created a frequency prefix array. For each possible target value i, calculated the total numbers within the [i - k, i + k] range. The frequency of i could be increased using available operations on nearby elements. Kept track of the best achievable frequency. ✔️ Time Complexity: O(N + M) - where M is the value range up to max(nums) + k. ✔️ Space Complexity: O(M) 🧠Key Takeaways: Prefix sums + frequency arrays are powerful for range-based computations. Always optimize loops around range-based frequency calculations. #Day153 #LeetCode #Arrays #PrefixSum #Frequency #Java #ProblemSolving #DSA #CodingChallenge #Algorithms #100DaysOfCode #InterviewPrep #SoftwareEngineering #DataStructures #CodeNewbie #ProgrammersLife
To view or add a comment, sign in
-
-
💡 (6th Nov 2025) Today I Learned: Functions & Methods (Part 3) Today’s session took functions beyond basics — applying them to real coding problems and understanding how scope works inside programs. Here’s what I explored 👇 1️⃣ Primes in a Range — Using loops and conditionals to print all primes between two numbers. 2️⃣ Binary to Decimal Conversion — Applying mathematical logic and functions to transform binary inputs. 3️⃣ Code: Binary to Decimal — Reinforcing function calls and arithmetic operations. 4️⃣ Decimal to Binary Conversion — Reversing the logic using division and remainders. 5️⃣ Code: Decimal to Binary — Practical exercise to solidify logic understanding. 6️⃣ Method Scope — Understanding how variables inside methods are accessible only within them. 7️⃣ Block Scope — How variables declared within a block { } exist only inside it. 🧩 Key Takeaway: Functions + Scope = Predictable & Maintainable Code. Knowing where your variables “live” in memory is just as important as writing efficient logic. #CodingJourney #Java #DSA #Functions #Programming #Scope #ApnaCollege #LearningInPublic #DeveloperGrowth
To view or add a comment, sign in
-
-
📌 Day 154 of Coding - Check If Digits Are Equal in String After Operations I (LeetCode - Medium) 🎯 Goal: Given a numeric string s, repeatedly replace it with a new string formed by taking the sum (mod 10) of every pair of adjacent digits, until only two characters remain. Return whether the final two digits are equal. 💡Approach & Debugging: Used a simple iterative simulation approach. For each iteration, formed a new string res by summing adjacent digits modulo 10. Replaced s with res and continued until the string length dropped to 2. Finally, compared both digits for equality. ✔️ Time Complexity: O(N*N) - since the string shrinks gradually each iteration. ✔️ Space Complexity: O(N) - temporary strings. 🧠 Key Takeaways: Some problems test simulation and string manipulation more than algorithms. Always track how input size evolves after each iteration. #Day154 #LeetCode #StringManipulation #Java #ProblemSolving #DSA #CodingChallenge #Algorithms #100DaysOfCode #InterviewPrep #SoftwareEngineering #DataStructures #CodeNewbie #ProgrammersLife
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