Print Shortest Common Supersequence | DP On Strings | Leetcode 1092 | DP Concepts & Qns-21
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 21st Video of our Playlist "DP Concepts & Qns".
This is the third 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 : Print Shortest Common Supersequence (Leetcode - 1092)
Shortest Common Supersequence - https://www.youtube.com/watch?v=MTCvNG4Zfd8
Printing LCS - https://www.youtube.com/watch?v=cVIOzjfxdbU
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 : Print Shortest Common Supersequence | DP On Strings | Leetcode 1092 | DP Concepts & Qns-21
Company Tags :
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/DP/DP%20on%20Strings/Print%20Shortest%20Common%20Supersequence.cpp
Leetcode Link : https://leetcode.com/problems/shortest-common-supersequence/
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 :
We follow the same approach as we did during Print LCS. We follow the DP table of Bottom Up Approach. The given code implements a dynamic programming approach to find the shortest common supersequence of two strings, `s1` and `s2`. The algorithm initializes a 2D array `t` to store the lengths of the shortest common supersequence for substrings of `s1` and `s2`. It iterates through both strings, filling up the array based on whether characters match or not. After populating the array, it reconstructs the shortest common supersequence by tracing back through the array, appending characters from `s1` and `s2` accordingly. Finally, it returns the constructed shortest common supersequence.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ 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