🚀 Day 110 of #100DaysOfCode ✅ Topic: Dynamic Programming — Longest Increasing Subsequence (LIS) 💡 Platform: GeeksforGeeks (Problem: Longest Increasing Subsequence) 🧠 Concept Learned: Today I practiced Dynamic Programming (DP) to find the length of the longest strictly increasing subsequence in an array. A subsequence is different from a subarray — elements need not be contiguous, only in increasing order. 📘 Approach Used: Initialize an array lis[] where lis[i] stores the length of the LIS ending at index i. For every element, check all previous elements to see if arr[i] > arr[prev]. If yes, update: lis[i] = max(lis[i], lis[prev] + 1) The final answer is max(lis) — the length of the longest subsequence. 🧩 Example: Input: arr = [5, 8, 3, 7, 9, 1] Output: 3 (Longest Increasing Subsequence → [5, 7, 9]) ✅ Result: All test cases passed (1111 / 1111) 🎯 Understood how Dynamic Programming helps break down complex problems into smaller overlapping subproblems efficiently.
Learned Dynamic Programming with GeeksforGeeks LIS problem
More Relevant Posts
-
In programming, particularly in object-oriented programming, a mixin is a class that provides methods and properties to other classes, without being their direct parent class in a traditional inheritance hierarchy. Mixins are designed to be "mixed in" with other classes, adding specific functionalities or behaviors to them. In Go, while there isn't a direct language feature explicitly called "mixins" , the concept can be effectively implemented using struct embedding and interfaces. This approach allows for the reuse of fields and methods across different structs, mimicking the behavior of mixins. How do we do that ? Struct Embedding: You can embed a struct (the "mixin" struct) within another struct. This makes the fields and methods of the embedded struct directly accessible as if they were part of the outer struct. The mixin pattern (implemented via struct embedding) in Go is primarily used for code reuse of common functionalities across otherwise unrelated structs and for managing cross-cutting concerns. #golang #backendDevelopment #mixins #learnfun #goLangTips
To view or add a comment, sign in
-
-
Mastering Clean Code: Top Tips for Cleaner Programming — Discover essential tips for mastering clean code and improving your programming skills with our expert guide. https://lnkd.in/gsvCCMng #CleanCode #CodeQuality #CodingBestPractices #DeveloperProductivity #ProgrammingTips #SoftwareDevelopment
To view or add a comment, sign in
-
-
Mastering Clean Code: Top Tips for Cleaner Programming — Discover essential tips for mastering clean code and improving your programming skills with our expert guide. https://lnkd.in/dazV2Vyc #CleanCode #CodeQuality #CodingBestPractices #DeveloperProductivity #ProgrammingTips #SoftwareDevelopment
To view or add a comment, sign in
-
-
Hii Developers👋 In programming, the most important skill isn’t memorizing syntax. It’s understanding logic and problem-solving. If you master logic, any language becomes easy to learn ✅ #Programming #LogicBuilding #SoftwareEngineering #TechJourney #LearnToCode
To view or add a comment, sign in
-
✅ Day 117: Number of Paths in a Matrix with K Coins Today’s #nationskillup challenge was a beautiful Dynamic Programming problem 🎯 — focused on counting the number of paths in a matrix where the sum of elements equals exactly K while moving from the top-left to the bottom-right cell. ⚡ Problem Statement: You are given a matrix mat[][] of size n × m, where each cell contains some coins. You can move only right or down, and you must collect exactly K coins by the time you reach the bottom-right cell. Find the total number of such paths. 🧠 Example: Input: k = 12 mat = [ [1, 2, 3], [4, 6, 5], [3, 2, 1] ] Output: 2 Explanation: There are 2 possible paths with sum = 12: 1️⃣ (1 + 2 + 6 + 2 + 1) 2️⃣ (1 + 2 + 3 + 5 + 1) 💡 Approach Summary: This problem can be solved using Dynamic Programming (DP) by maintaining a DP table where dp[i][j][sum] represents the number of ways to reach cell (i, j) with total coins = sum. We optimize space by keeping only two 2D arrays — prev and curr. At each cell (i, j) and sum value, we add the number of ways from the top and left cells if the remaining sum is valid. 🔹 Recurrence Relation: dp[i][j][sum] = dp[i-1][j][sum - mat[i][j]] + dp[i][j-1][sum - mat[i][j]] 🔹 Base Case: If (i, j) == (0, 0), then dp[0][0][sum] = 1 if sum == mat[0][0] 🧩 Time Complexity: O(n × m × k) 🧠 Space Complexity: O(m × k) 🤝 Thanks to GeeksforGeeks and Sandeep Jain Sir for helping us understand how combinatorial problems can be solved with elegant recurrence relations! 🙌 Shoutout to Jagan Mohan Jangam for keeping the #nationskillup challenge alive and motivating every day! 🚀 📚 Course Link: https://lnkd.in/gyueNByH #skillupwithgfg #nationskillup #DynamicProgramming #Java #GeeksforGeeks #CodingChallenge #CodeEveryday
To view or add a comment, sign in
-
-
Understanding Inheritance in Object-Oriented Programming using Ben 10! Inheritance is one of the core principles of Object-Oriented Programming that allows us to create hierarchical relationships between classes. Let me explain this concept using everyone's favorite childhood hero - Ben 10! >> What This Image Illustrates: The diagram shows Ben Tennyson at the center, representing the PARENT CLASS (or Base Class). He possesses the Omnitrix, which gives him the fundamental ability to transform. Surrounding him are his various alien forms - Heatblast, Four Arms, and other transformations. Each of these represents a CHILD CLASS (or Derived Class) that inherits properties from Ben. > How Inheritance Works Here: • PARENT CLASS (Ben): Contains common attributes like the Omnitrix, transformation ability, and basic hero characteristics that ALL aliens share • CHILD CLASSES (Aliens): Each alien inherits these base properties BUT also has unique specialized abilities: - Heat blast: Inherits from Ben + Fire manipulation powers - Four Arms: Inherits from Ben + Super strength and combat skills - XLR8: Inherits from Ben + Super speed abilities >> Real-World Benefits: > Code Reusability: Write common functionality once in the parent, automatically available to all children > Maintainability: Update the parent class, and all child classes benefit > Logical Structure: Mimics real-world relationships ("is-a" relationship) > Extensibility: Add new alien forms without changing existing code > Why This Matters in Software Development: Just like Ben doesn't need to relearn how to be a hero with each transformation, in programming we don't need to rewrite common functionality for each class. Inheritance helps us build efficient, scalable, and organized code structures. Think of it as: Every alien "is a" Ben with special powers added on top! #OOP #ObjectOrientedProgramming #Inheritance #SoftwareDevelopment #Programming #CodingConcepts #TechEducation #LearnToCode #Java #Python #JavaScript #SoftwareEngineering #Ben10 #TechExplained
To view or add a comment, sign in
-
-
Object-oriented programming is one of the most widely-used programming paradigms in software development. And in this detailed guide, Lucas shows you how it works in TypeScript. You'll learn key TS language features like objects, classes, & interfaces, then see how they give rise to the four pillars of OOP: inheritance, polymorphism, encapsulation, and abstraction. https://lnkd.in/d7j2A8ib
To view or add a comment, sign in
-
-
"Mastering LeetCode patterns is a game-changer for acing coding interviews and building robust algorithms. This fantastic visual guide covers 15 must-know patterns from Prefix Sum to Dynamic Programming. Which one is your favorite to tackle? Let me know in the comments! 👇 #LeetCode #CodingInterviewPrep #DataStructures #Algorithms #Programming #SoftwareDevelopment #Tech"
To view or add a comment, sign in
-
-
💯 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
-
-
Programming has changed over time, but, the fundamentals haven't. And I dont think they ever will. Build a solid base first (variables, conditionals, loops etc) You can always build on top of that according to your requirement. Share your thoughts. Follow for more!
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