Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 92nd Video of our Playlist "Dynamic Programming : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a very good DP problem based on LIS Variant : Longest Ideal Subsequence | LIS Variant | Bottom Up | Optimal | Leetcode 2370 | codestorywithMIK
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Longest Ideal Subsequence | LIS Variant | Bottom Up | Optimal | Leetcode 2370 | codestorywithMIK
Company Tags : will update soon
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/longest...
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Subscribe to my channel : / @codestorywithmik
Approach Summary :
Approach-1: This approach utilizes the Longest Increasing Subsequence (LIS) algorithm to find the length of the longest ideal string in a given string `s`. It iterates through each character of `s` and for each character, it checks all previous characters to find the maximum length of an ideal subsequence that can be formed ending at that character. Time complexity is O(n^2) because of nested loops where n is the length of the string `s`. Space complexity is O(n) because of the additional storage required for the `t` vector.
Approach-2: This approach optimizes the previous approach by only considering characters within a certain range around the current character `s[i]`. It maintains an array `t` of size 26 to store the length of the longest ideal subsequence ending at each character in the alphabet. It iterates through each character of `s`, calculates the range of characters to consider based on the difference `k`, and updates the length of the longest ideal subsequence ending at the current character accordingly. Time complexity is O(n) as it iterates through the string once, and space complexity is O(1) since the size of the auxiliary array `t` is fixed.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #newyear2024