Edit Distance | Recursion | Memo | Bottom Up | DP On Strings | Leetcode 72 | DP Concepts & Qns-21

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



Duration: 58:11
1,261 views
47


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

This is the fourth 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 : Edit Distance (Leetcode - 72)

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 : Edit Distance | Recursion | Memo | Bottom Up | DP On Strings | Leetcode 72 | DP Concepts & Qns-21 | codestorywithMIK
Company Tags : Amazon, Goldman Sachs, Microsoft, Google
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/DP/Edit%20Distance.cpp
Leetcode Link : https://leetcode.com/problems/edit-distance/


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 :
Sure, here's a small summary of each approach:

1. **Approach-1 (Recur + Memo, starting from m, n):**
- This approach uses recursion with memoization.
- It starts comparing the strings from the end.
- If the characters at the current positions are equal, it moves to the next positions in both strings.
- If the characters are not equal, it considers three operations: insert, delete, and replace, and recursively calculates the minimum cost for each operation.
- Time Complexity: O(m*n) where m and n are the lengths of the input strings.
- Space Complexity: O(m*n) for memoization table t.

2. **Approach-2 (Recur + Memo, starting from i = 0, j = 0):**
- Similar to Approach-1, but it starts comparing the strings from the beginning.
- It considers the lengths of the remaining portions of the strings and calculates the edit distance accordingly.
- Time Complexity: O(m*n) where m and n are the lengths of the input strings.
- Space Complexity: O(m*n) for memoization table t.

3. **Approach-3 (Bottom-Up DP derived from Approach-1):**
- This approach uses bottom-up dynamic programming.
- It fills up a 2D table iteratively, where t[i][j] represents the minimum edit distance between the substrings s1[0...i-1] and s2[0...j-1].
- It starts with base cases where either string is empty and iterates through the rest of the table, updating values based on the previous values.
- Time Complexity: O(m*n) where m and n are the lengths of the input strings.
- Space Complexity: O(m*n) for the bottom-up dynamic programming table t.

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

✨ Timelines✨
00:00 - Introduction
03:56 - Thought Process
06:00 - Tree Diagram
19:51 - Story To Code
26:21 - Coding Recursion+Memo - 1
31:11 - Understanding Recursion+Memo - 2
41:13 - Coding Recursion+Memo - 2
43:19 - Why I prefer Recursion+Memo - 2
49:14 - Bottom Up
56:11 - Coding Botton Up

#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-04-26Minimum Falling Path Sum II | 4 Approaches | Detailed Dry Run | Leetcode 1289 | codestorywithMIK
2024-04-24Longest Ideal Subsequence | LIS Variant | Bottom Up | Optimal | Leetcode 2370 | codestorywithMIK
2024-04-23N-th Tribonacci Number | 3 Approaches | AMAZON | Leetcode 1137 | codestorywithMIK
2024-04-22Minimum Height Trees | Know Every Detail | Why BFS | GOOGLE | Leetcode 310 | codestorywithMIK
2024-04-21Open the Lock | Why BFS | Similar Pattern Problems | META | Leetcode 752 | codestorywithMIK
2024-04-21Find Edges in Shortest Paths | Dijkstra's Algo | Full Intuition | Leetcode 3123 | codestorywithMIK
2024-04-20Find All Groups of Farmland | DFS | BFS | Brute Force | Leetcode 1992 | codestorywithMIK
2024-04-18Number of Islands | DFS | BFS | Same as Island Perimeter | Leetcode 200 | codestorywithMIK
2024-04-17Island Perimeter | 3 Approaches | Google | Leetcode 463 | codestorywithMIK
2024-04-16Smallest String Starting From Leaf | DFS | BFS | Google | Leetcode 988 | codestorywithMIK
2024-04-14Edit Distance | Recursion | Memo | Bottom Up | DP On Strings | Leetcode 72 | DP Concepts & Qns-21
2024-04-13Sum of Left Leaves | 2 Approaches | META | Leetcode 404 | codestorywithMIK
2024-04-12Maximal Rectangle | Multiple Hidden Problems | Intuition | Leetcode 85 | codestorywithMIK
2024-04-12One Love = CODING ❤️👨🏻‍💻
2024-04-10Remove K Digits | Intuition | Dry Run | Leetcode 402 | codestorywithMIK
2024-04-09Reveal Cards In Increasing Order | 2 Approaches | Leetcode 950 | codestorywithMIK
2024-04-09Time Needed to Buy Tickets | 3 Approaches | Leetcode 2073 | codestorywithMIK
2024-04-07Number of Students Unable to Eat Lunch | 2 Approaches | Leetcode 1700 | codestorywithMIK
2024-04-07Minimum Cost Walk in Weighted Graph | Thought Process | DSU | Leetcode 3108 | codestorywithMIK
2024-04-07Valid Parenthesis String | 4 Detailed Approaches | Leetcode 678 | codestorywithMIK
2024-04-06Print Shortest Common Supersequence | DP On Strings | Leetcode 1092 | DP Concepts & Qns-21