Shortest Common Supersequence | 3 Approaches | DP On Strings |DP Concepts & Qns 20|codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=MTCvNG4Zfd8



Duration: 53:05
626 views
22


Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 20th Video of our Playlist "DP Concepts & Qns".

This is the second video of the "DP On Strings" series in this playlist.
In this video we will try to solve a very good and famous DP problem : Shortest Common Supersequence
Longest Common Subsequence (LCS Video) - https://www.youtube.com/watch?v=aJNu_DLyOxY

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 : Shortest Common Supersequence | 3 Approaches | DP On Strings | DP Concepts & Qns-20
Company Tags : Microsoft
My solutions on Github(C++ & JAVA) :
GfG Problem Link : https://www.geeksforgeeks.org/problems/shortest-common-supersequence0322/1


My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK

Approach Summary :
**Approach-1 (Recursion + Memoization):**
- This approach utilizes recursion with memoization to find the length of the shortest common supersequence of two strings.
- Time Complexity (T.C): O(m * n), where m and n are the lengths of the input strings.
- Space Complexity (S.C): O(m * n) for the memoization table.
- It stores intermediate results in a memoization table to avoid redundant calculations during recursion.

**Approach-2 (Bottom Up):**
- This approach uses a bottom-up dynamic programming approach to find the length of the shortest common supersequence.
- It iterates through the strings and fills a 2D table to store the lengths of the shortest common supersequence.
- Time Complexity (T.C): O(m * n), where m and n are the lengths of the input strings.
- Space Complexity (S.C): O(m * n) for the dynamic programming table.

**Approach-3 (Using LCS Code):**
- This approach repurposes the Longest Common Subsequence (LCS) algorithm to find the length of the shortest common supersequence.
- It computes the LCS of the input strings and then calculates the length of the shortest common supersequence based on the LCS.
- Time Complexity (T.C): O(m * n), where m and n are the lengths of the input strings.
- Space Complexity (S.C): O(m * n) for the dynamic programming table used to compute LCS.
- After finding the LCS, it calculates the number of letters that are not part of LCS in each string and adds them to the LCS length to obtain the length of the shortest common supersequence.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

✨ Timelines✨
00:00 - Introduction
04:51 - Intuition & Thought Process (Recursion + Memo)
12:46 - Tree Diagram
23:25 - Story To Code
32:01 - Coding Approach-1 (Recursion + Memo)
35:39 - Approach-2 Bottom Up
42:01 - Coding Approach-2 (Bottom Up)
44:21 - Approach-3 (Using LCS)
51:34 - Coding Approach-3 (Using LCS)

#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




Other Videos By codestorywithMIK


2024-03-25First Missing Positive | In Depth Intuition | Clean Code | Leetcode 41 | codestorywithMIK
2024-03-24Longest Common Suffix Queries | Simple TRIE | Clean Code | Leetcode 3093 | codestorywithMIK
2024-03-24Most Frequent IDs | Complete Intuition | Leetcode 3092 | codestorywithMIK
2024-03-22Reorder List | 3 Approaches | Leetcode 143 | codestorywithMIK
2024-03-21Palindrome Linked List | 4 Approaches | Leetcode 234| codestorywithMIK
2024-03-20Task Scheduler | Using Greedy Only | No Heap | Leetcode 621 | codestorywithMIK
2024-03-19Merge In Between Linked Lists | Easy Straight Forward | AMAZON | Leetcode 1669 | codestorywithMIK
2024-03-18Task Scheduler | Easy Intuition | Using Heap | Leetcode 621 | codestorywithMIK
2024-03-17Minimum Deletions to Make String K-Special | 2 Simple Approaches | Leetcode 3085 | codestorywithMIK
2024-03-16Count Substrings Starting and Ending with Given Character | Leetcode 3084 | codestorywithMIK
2024-03-16Shortest Common Supersequence | 3 Approaches | DP On Strings |DP Concepts & Qns 20|codestorywithMIK
2024-03-15Contiguous Array | Using same Pattern Approach | Similar Problems | Leetcode 525
2024-03-15Trie VS Tree
2024-03-14Binary Subarrays With Sum | 2 Approaches | Detailed Explanation | Leetcode 930
2024-03-13Find the Pivot Integer | 5 Approaches | Easy Explanation | Leetcode 2485
2024-03-12Regular Expression Matching | Brute Force | Optimal | Recursion Concepts And Questions
2024-03-11Shortest Uncommon Substring in an Array | Detailed Intuition | Dry Run | Leetcode 3076 | Contest 388
2024-03-10Custom Sort String | 2 Approaches | Intuition | Meta | Leetcode 791
2024-03-10Maximum Strength of K Disjoint Subarrays | Recursion | Memoization | Leetcode 3077 | Contest 388
2024-03-09Intersection of Two Arrays | 4 Approaches | Leetcode 349
2024-03-08Minimum Common Value | 3 Approaches | Leetcode 2540