Back to Browse

Remove all adjacent duplicates in string recursive solution | LeetCode Easy Problem 1047

297 views
Sep 2, 2020
23:33

Haven't done a LeetCode video in a few months so I'm probably a little rusty but at least we've improved the video quality! Showing and explaining my thought process for working through a LeetCode problem and run Timestamps: 00:00 Reading out the problem 01:00 Stating assumptions and thought process for solving the problem 06:30 Starting coding the two pointer recursive approach 11:10 Maximum Recursion depth exceeded from no base case 12:45 Still getting the wrong output for some reason 14:30 Printing Foo to check our recursive call count for debugging 15:45 Hacking together appending the last character of the string 18:00 Answer Accepted! Or is it? 19:00 Finding a new failure case our algorithm didn't check for 20:00 Appending a skipped character to the end of our string 21:33 SUCCESS! Poor runtime which we assumed but less than 81.80% memory usage In the problem I use a two pointer approach to remove duplicate letters from a string and then call our function recursively to check the new string that gets formed after doing the removals. Remember to subscribe for the follow up where we shift the string inline and solve this in a single pass without the recursion. For more Python and Software Development related articles check out our blog: https://beapython.dev/

Download

1 formats

Video Formats

360pmp434.0 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Remove all adjacent duplicates in string recursive solution | LeetCode Easy Problem 1047 | NatokHD