Revisiting this two-pointer problem on LeetCode. Last time, I didn't pay much attention to the Dynamic Programming solution which is very insightful. I'd recommend considering all known approaches to a solution to understand the topics better. Turns out that the simpler two-pointer solution to this one ran faster for me than the Dynamic Programming solution. 5. Longest Palindrome Substring https://lnkd.in/gX8GRDJV
Revisiting LeetCode's Longest Palindrome Substring problem with two-pointer and Dynamic Programming solutions.
More Relevant Posts
-
💯 Day 7/100: Dynamic Programming — LeetCode 474 Today’s challenge was a classic optimization puzzle: selecting the largest subset of binary strings under strict limits on the number of 0s and 1s. It’s essentially a two-dimensional knapsack problem, where each string consumes a portion of your limited resources. The key breakthrough was realizing that you need to traverse the DP table in reverse to preserve state dependencies. Each update reflects the best outcome when including a new string, without overwriting previous possibilities. This problem sharpened my understanding of multi-dimensional constraints and reinforced the importance of state reuse in dynamic programming. It’s a great reminder that even medium-difficulty problems can hide deep algorithmic insights. Onward to Day 8 — the grind continues. #100DaysOfCode #LeetCode #DynamicProgramming #TechJourney #ScarCodes #ProblemSolving #CodeChallenge #SoftwareEngineering
To view or add a comment, sign in
-
-
💻 Meaningful Names I've been slowly reading Clean Code by Robert C. Martin. Chapter 2 is about Meaningful Names—arguably the most basic principle in programming, yet one of the easiest to overlook in practice. I often find myself spending quite a bit of time naming variables or functions. But this chapter reminded me that it's not wasted time at all. A good name is like a door—it’s the first thing we see, and it guides our assumptions about what lies behind it. When names are clear and intentional, the rest of the code becomes so much easier to follow. It’s a small thing that makes a huge difference.
To view or add a comment, sign in
-
💡 We all know how much time we spend trying to find the perfect variable name — and it still never feels quite right 😅 A good variable name should be clear, unambiguous, and easy to understand for anyone reading your code. Here’s an excellent naming cheat sheet that breaks down the best practices and rules for naming things in programming 👇 🔗 https://lnkd.in/dA_Qupn9 #CleanCode #NamingConventions #SoftwareEngineering #ProgrammingTips #CodeQuality #CodingStandards #CodeReview
To view or add a comment, sign in
-
-
Day 7/50 – Intro to Competitive Programming! Platform: Codeforces (CF 800 Rating) Topic: Implementation, Basic Logic, Ad-Hoc Difficulty: Beginner Core Recap: Today I switched gears from LeetCode to tackle the famous 800-rated beginner problems on Codeforces. This is the starting line for competitive programming. These problems aren't about complex DSA; they're about logic, math, and flawless implementation. Problems Solved: A - Watermelon A - Way Too Long Words A - Team A - Domino piling Logic: These problems are designed to test your fundamentals. "Watermelon" is a classic logic puzzle. The code is one line, but you have to find the trick (checking for an even number greater than 2). "Way Too Long Words" is a pure test of string handling and if/else logic. "Team" & "Domino piling" are about correctly reading the problem, understanding the simple math, and implementing it without bugs.
To view or add a comment, sign in
-
-
Recursion Definition: Recursion is a programming technique where a function calls itself directly or indirectly to solve a problem. It works by breaking down a complex problem into smaller, similar sub-problems until a base case is reached, which provides a direct solution.
To view or add a comment, sign in
-
-
Why does the code break? The answer is very obvious too. Any library got an update, something got deprecated or it may rely on a connection which got broken. . 💔 Understanding why code breaks is a complex part and understanding it is actually part of programming too.
To view or add a comment, sign in
-
🔥 Day 19 of LeetCode Challenge – Problem #213: House Robber II Today’s challenge was a dynamic programming problem that extends the classic House Robber concept into a circular arrangement. 💡 Concept Overview: In this variation, the first and last houses are adjacent — which means robbing both is not allowed. The challenge is to maximize profit without triggering alarms in this circular setup. 🧩 Approach Used: Handled base cases for arrays of size 1 and 2. Split the circular problem into two linear subproblems: 1️⃣ Rob houses from index 0 to n-2 2️⃣ Rob houses from index 1 to n-1 Used a helper function with Dynamic Programming (DP) to calculate the maximum money that can be robbed in each case. The final answer is the maximum of both results. ⚙️ Algorithm Used: Dynamic Programming 🧾 Language: Java ⏱ Runtime: 0 ms (beats 100%) 💾 Memory: 42.84 MB 📈 Key Insight: Transforming a circular dependency problem into two linear DP runs simplifies complexity and ensures optimal results. #LeetCodeJourney #100DaysOfCode #CodeNewbie #DeveloperCommunity #JavaDeveloper #CodingPractice #AlgorithmDesign #CareerGrowth #TechInnovation #KeepLearning
To view or add a comment, sign in
-
-
Stop duplicating code! My latest blog post is out, and it's all about Generic Programming. Learn how this powerful paradigm helps you write reusable, type-safe, and highly efficient code. It's an essential concept for any modern developer looking to level up their craft. Ready to cut down on boilerplate? https://lnkd.in/evXA4muA #GenericProgramming #SoftwareEngineering #TechBlog #ProgrammingTips #CodeQuality
To view or add a comment, sign in
-
If you want to improve your programming skills, try comparing and contrasting similar code. In this in-depth guide, Evaristo walks you through five different versions of a Rock, Paper, Scissors game in JavaScript. You'll use System Block Diagrams to analyze each project, dissect their methodologies, and learn how to build mental models. https://lnkd.in/g26ynuYf
To view or add a comment, sign in
-
More from this author
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
Isn't that a direct knowledge check for a manacher algorithm?