Day 17 of Problem-Solving Discipline 🚀 Today’s focus was LeetCode 3047 – Find the Largest Area of Square Inside Two Rectangles, solved using logical optimization and a clean, readable JavaScript implementation. This problem was a strong reminder that good engineering isn’t about writing more code — it’s about understanding constraints deeply. By applying geometry fundamentals and carefully analyzing boundaries, a brute-force thought process naturally transformed into an efficient and elegant solution. 📌 Key takeaways from today’s practice: • Reducing problems by identifying minimum limiting factors • Shifting mindset from repeated iterations to optimal condition evaluation • Writing code that is not only correct, but readable, maintainable, and test-case safe What I’m learning daily is that consistency beats intensity. Small improvements, practiced regularly, compound into strong problem-solving intuition over time. Showing up every day. One problem at a time. Building long-term engineering strength. #LeetCode #JavaScript #ProblemSolving #DSA #CodingJourney #SoftwareEngineer #DailyConsistency #LearningInPublic
LeetCode 3047: JavaScript Optimization for Largest Square Area
More Relevant Posts
-
Do you know about Hell? The hell in coding? It is 'Callback hell.' Callback Hell is not a beginner problem. It’s a bad design problem. You start innocent. One API call. Then another. Then another. Suddenly, your code looks like a staircase designed by chaos. This is callback hell, aka pyramid of doom. Why it’s hell: Your code is unreadable. Error handling is a joke. Debugging feels like archaeology. One small change breaks five things. New devs fear touching your file. If you’re still writing code like this in 2026, that’s on you. The fix is not magic. It’s discipline. Use Promises Use async / await Split logic into small, named functions Handle errors once, not everywhere Stop nesting like it’s 2012 Bad code works. Good code scales. Clean code survives teams, time, and pressure. If your code gives you anxiety, it’s trying to tell you something. #JavaScript #WebDevelopment #CleanCode #AsyncAwait #Programming #MERN #SoftwareEngineering
To view or add a comment, sign in
-
-
𝗪𝗲𝗹𝗰𝗼𝗺𝗲 𝘁𝗼 𝗗𝗮𝘆 𝟭𝟯 𝙃𝙤𝙬 𝙅𝙖𝙫𝙖𝙎𝙘𝙧𝙞𝙥𝙩 𝙂𝙖𝙧𝙗𝙖𝙜𝙚 𝘾𝙤𝙡𝙡𝙚𝙘𝙩𝙞𝙤𝙣 𝙒𝙤𝙧𝙠𝙨 Your code doesn’t free memory. JavaScript does. But it only removes what is unreachable. 𝙍𝙚𝙖𝙘𝙝𝙖𝙗𝙞𝙡𝙞𝙩𝙮 An object stays in memory if there is a reference path from the roots. Roots: • Global scope • Execution stack • Active closures No path → eligible for garbage collection. 𝙈𝙖𝙧𝙠 & 𝙎𝙬𝙚𝙚𝙥 • Start from the roots and mark all reachable objects • Remove everything unmarked Reachable stays. Unreachable is freed. 𝙂𝙚𝙣𝙚𝙧𝙖𝙩𝙞𝙤𝙣𝙖𝙡 𝘾𝙤𝙡𝙡𝙚𝙘𝙩𝙞𝙤𝙣 Most objects die young. Memory is divided into: • Young generation → short-lived objects, frequent fast cleanup • Old generation → long-lived objects, less frequent cleanup 𝙋𝙧𝙤𝙢𝙤𝙩𝙞𝙤𝙣 Every object starts in the young generation. If it survives multiple GC cycles or memory pressure increases, it gets promoted to the old generation. Survival determines placement. 𝙒𝙝𝙮 𝙈𝙚𝙢𝙤𝙧𝙮 𝙇𝙚𝙖𝙠𝙨 𝙎𝙩𝙞𝙡𝙡 𝙃𝙖𝙥𝙥𝙚𝙣 GC removes only unreachable objects. Leaks occur when references are retained: • Globals • Closures • Timers / event listeners • Growing caches 𝘎𝘊 𝘸𝘰𝘳𝘬𝘴 𝘤𝘰𝘳𝘳𝘦𝘤𝘵𝘭𝘺. 𝘠𝘰𝘶𝘳 𝘳𝘦𝘧𝘦𝘳𝘦𝘯𝘤𝘦𝘴 𝘥𝘦𝘤𝘪𝘥𝘦 𝘸𝘩𝘢𝘵 𝘭𝘪𝘷𝘦𝘴. #JavaScript #WebDevelopment #SoftwareEngineering #FrontendDevelopment #Programming #Coding #Developers #TechCommunity #ComputerScience #PerformanceOptimization #Learning #ContinuousLearning #LearnInPublic
To view or add a comment, sign in
-
-
𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝘃𝘀 𝗠𝗲𝘁𝗵𝗼𝗱𝘀 — 𝘄𝗵𝗮𝘁’𝘀 𝘁𝗵𝗲 𝗿𝗲𝗮𝗹 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲? A 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻 is a standalone block of logic. It exists independently and doesn’t belong to any object. A 𝗺𝗲𝘁𝗵𝗼𝗱 is a function that belongs to an object or class. It operates on the data owned by that object. So, can we call a method a function? Technically, yes. Conceptually, no. Under the hood, a method is a function. But once a function is attached to an object, we call it a method to describe its role. Example in JavaScript: parseInt() → function array.map() → method (a function bound to an array) Calling everything a function isn’t wrong, but it hides intent. Using the right term makes your design clearer and your code easier to reason about. #Programming #JavaScript #WebDevelopment #SoftwareEngineering #CodingConcepts #ComputerScience #CleanCode #CodeClarity #DevTips #LearningToCode #MERN #FrontendDevelopment #BackendDevelopment
To view or add a comment, sign in
-
-
The hell of parsers. One day, you think you’ve written a simple unit test. The next day, you realize you’ve opened a crack in the geometry of JavaScript. I was testing what felt like a safe invariant: source code → structure → source code. No transformation. No creativity. Just fidelity. And yet, something vanished. No error. No crash. No warning. Just a quiet absence. That’s when you learn the hard lesson: in JavaScript, structure is not always where you expect it to be. Some constructs don’t live inside what they initialize. They orbit it. Parsers rarely fail loudly. They fail silently and structurally. And once you see it, you can’t unsee it. Welcome to the hell of parsers. #Programming #JavaScript #Parsing #AST #Compilers #SoftwareEngineering #SystemsThinking #DeveloperLife #DeepTech #UnderTheHood
To view or add a comment, sign in
-
-
Hoisting isn't magic. It's Memory Management. 🧠 Many developers think Hoisting means "JavaScript moves code to the top of the file." That is a myth. Your code doesn't move anywhere. What actually happens? JavaScript execution has two phases: Memory Creation Phase: The engine scans your code and allocates memory for variables/functions. Execution Phase: The code actually runs. This creates 3 distinct behaviors: ✅ Function Declarations: The engine copies the entire code into memory. (Fully usable). ⚠️ var Variables: The engine allocates memory but sets the value to undefined. ❌ let & const: The engine allocates memory but forbids access (Temporal Dead Zone). Understanding this difference separates a Junior Dev from a Senior Dev. It’s not just about syntax; it’s about understanding the Execution Context. Save this for your next architectural discussion! 💾 #javascript #programming #tech #webdev #coding #computerscience
To view or add a comment, sign in
-
One Instance, Many Consequences: Rethinking the Singleton 🧩 Today’s learning spanned JavaScript design patterns and prompt engineering fundamentals. On the Singleton pattern in JS, I learned: -How Object.freeze helps enforce immutability -Why Singleton is often considered an anti-pattern -Tradeoffs around testing difficulty, hidden dependencies, and implicit global behavior On prompt engineering, I went deeper into prompt structure: -Core elements: instructions, context, input data, output indicators -Avoiding imprecise prompts -Asking models to focus on what to do, not what not to do, for more accurate outputs Key takeaway: Good engineering whether code or prompts is about clarity, explicit intent, and understanding tradeoffs. #JavaScript #DesignPatterns #SingletonPattern #PromptEngineering #LLM #AIEngineering #LearnInPublic
To view or add a comment, sign in
-
Day 8 of 30-day Coding Sprint Today’s focus was on a classic problem that teaches you why linear time isn't always good enough when dealing with exponents. Today's progress on LeetCode: 50. Pow(x, n) The Simple Recursive Approach: Multiplying x by itself n times. - Complexity: O(n) time. - The Issue: For large values of n, this hits the stack limit or simply takes too long. The Optimal Strategy: Binary Exponentiation (Divide & Conquer) - The Logic: Use the property (x^n) = (x^n/2)^2. By halving n at each recursive step, we drastically reduce the number of multiplications. The Result: O(log n) time. This turns a billion operations into roughly 30. #30DaysOfCode #DSASprint #LeetCode #JavaScript #Recursion #Math #Consistency
To view or add a comment, sign in
-
-
🚀 Codewars Kata Reflection: “What’s the Real Floor?” (8 kyu, JavaScript) Today I revisited a deceptively simple Codewars challenge that reinforced an important lesson: clarity in problem modeling beats complexity in code. 🧠 The problem American and European floor numbering systems differ: In the US, the 1st floor is actually the ground floor There is no 13th floor Basements (negative floors) remain unchanged The task was to convert an American floor number into its European equivalent. 💡 Why the solution works function getRealFloor(n) { return n <= 0 ? n : n < 13 ? n - 1 : n - 2; } This works because it mirrors the real-world rules directly: Basements (n <= 0) These are universal - no transformation needed. Floors 1-12 Since “1” maps to ground floor, all values shift down by 1. Floors above 13 Two numbers are missing below them: Floor 1 (ground floor) Floor 13 So we shift down by 2. Instead of looping or mapping values, the logic is handled with simple conditional branching, making the intent obvious and the behavior predictable. ⚡ Time & Space Complexity Time Complexity: O(1) - constant time, no loops, no recursion Space Complexity: O(1) - no additional memory allocated. 📚 What I learned 1. Not every problem needs iteration - sometimes rules are enough 2. Writing code that reflects real-world constraints leads to simpler solutions 3. Even beginner-level katas are great for sharpening logic, edge-case thinking, and code expressiveness. Small challenges, big reminders. On to the next kata 🧩💪 #Codewars #JavaScript #ProblemSolving #CleanCode #SoftwareEngineering #LearningInPublic #Algorithms
To view or add a comment, sign in
-
-
Not a lot of engineers feel comfortable programming without writing loops. I get it. Loops feel like control. But the more asynchronous programming you do, the more you realize you often do not need them. You start thinking in flows instead of steps. You lean on map, filter, forEach, for...of, promises, streams, and events. That shift quietly changes how you see problems. A function that recommends movies in a Netflix-like app and a function that handles drag and drop interactions look totally different on the surface. But structurally, they are cousins. Both consume a stream of inputs over time and produce outputs as reactions. Same shape, different domain. I think we inherited a confusing mental model. Iterators and observers were described as separate ideas. Events and arrays were treated like unrelated concepts. In practice, they are closer than we think. Arrays are finite data streams. Events are potentially infinite data streams. The real missing piece in older JavaScript was a clean way to say, "this stream is done, no more data is coming." Async iterators quietly fixed that. The code snippet below is a small example that treats events like an async iterable and lets you use for...of instead of a callback. No need for manual loops with counters or nested callbacks. Just a stream of values you can consume like an array. Once you start seeing arrays, events, API responses, user behavior, and real-time data as the same abstract thing, streams of values over time, your code gets simpler, and your architecture gets sharper. #JavaScript #AsyncProgramming #SoftwareEngineering #Frontend #Programming
To view or add a comment, sign in
-
-
Day 43 of me reading random and basic but important coding topicsss..... After what why and how of event delegation I read about its Performance impacts and use cases... 1. The Performance Impact Memory Footprint:- Imagine a table with 1,000 rows. Bad Way: 1,000 separate event handlers attached to 1,000 elements. Each handler is an object in memory. Delegated Way: 1 single handler on the <table>. Result: Massive memory savings and less work for the browser during garbage collection. Initialization Speed: Attaching 1,000 listeners takes time (DOM blocking). Attaching 1 takes microseconds. Page becomes interactive faster. 2. Real-World Use Case:- * Dynamic Content This is the #1 reason to use delegation. Scenario: You have an "Infinite Scroll" feed (like LinkedIn or Twitter). The Problem: If you use direct binding, every time you fetch new posts via AJAX, you have to manually attach new listeners to the new DOM nodes. The Solution: With delegation on the main feed container, you do nothing. The container is already listening. New child elements are automatically covered the moment they appear in the DOM. * Global Behaviors You can implement Global Tooltips or Toggles without writing component-specific code. Strategy: Attach a listener to document.body. Logic: If any element with data-tooltip is hovered, show the tooltip text. Benefit: You can now add tooltips to any component in your app just by adding an HTML attribute, without touching a single line of JavaScript. 3. Trapssss:- The stopPropagation Trap: If we add event.stopPropagation() on a child element, the delegation handler on the parent will never fire. Delegation requires the bubble to stay intact. Non-Bubbling Events: Events like focus and blur do not bubble. You must use focusin / focusout to delegate form interactions. The Verdict: Event Delegation is the difference between an app that slows down as it grows and an app that scales effortlessly. Keep Learning!!!! #WebPerformance #SoftwareEngineering #JavaScriptDev #Scalability #FrontendOptimization
To view or add a comment, sign in
-
Explore related topics
- Leetcode Problem Solving Strategies
- Build Problem-Solving Skills With Daily Coding
- Tips for Engineers to Enhance Problem-Solving Skills
- LeetCode Array Problem Solving Techniques
- Tips for Problem-Solving with Clarity
- How to Shift Focus from Problems to Solutions
- Importance of Problem Obsession in Engineering
- Writing Elegant Code for Software Engineers
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