yet so in that case we would go down in the opposite case if we used this b we cross it out we can still use this one but we can only use two characters from here so in that case we would go to the right now if either of these in this case we can go in both directions if either the bottom neighbor is true or the right neighbor is true then we can put true in this position if they were both false then we can't put false if only then we can't put true if only one of them was true then we can also put true now let's dive into the coding portion but before i do let me just give you a quick word from today's sponsor if you want to get hired at top tech companies like google facebook and amazon then you need to check out interviewing dot io you'll practice realistic coding interviews with senior engineers who will give you detailed feedback on exactly what you need to work on they have the largest network of vetted and experienced tech interviewers in the world so you can book an interview with as little as NUMBER_TOKEN hours notice and the best part you don't even have to pay until you get hired please check out the link in the description below for more details so in the interest of time i'm just going to skip and show you what the memoization recursive solution looks like and then we're going to code up the dynamic programming solution so we do have a cache in this case it's going to be a hash map and you can see we're passing in two pointers into our function just like we did in the drawing right and our base case is yes if i and j are out of bounds then we can return true that's one base case another base case is if this position has already been computed meaning it's already in the dynamic programming cache then we can just return the result now if that's not the case then we have to go into our recursive case you might not be able to tell but yes this is recursion because we're checking if i is still in bounds right because technically one of the strings could be out of bounds so if i is in bounds then we're gonna check does the character in string one i basically is the pointer for string one does that character match the target position we're looking at in string three like i said we're taking i plus j the two pointers adding them together to find the target character in string three so if the characters match then we're going to take i and increment it by one right we're incrementing it by one because we're saying we just used the character from string one now the next two lines of code are the exact opposite if the string if the character if the pointer in string two is inbounds and that character in stringNUMBER_TOKEN matches the target character then we're gonna take dfs and increment j by one saying we just used the character in string two and if that returns true then we can return true in either of these cases we don't have to cache that because if we find one valid result then we can immediately return true from the root function if neither of them return true then we have to dp cache this as false and then return false because we don't have to repeat the work again so that's the entire function i bet it's a little bit easier
START_SPONSOR_TOKEN do let me just give you a quick word from today's sponsor if you want to get hired at top tech companies like google facebook and amazon then you need to check out interviewing dot io you'll practice realistic coding interviews with senior engineers who will give you detailed feedback on exactly what you need to work on they have the largest network of vetted and experienced tech interviewers in the world so you can book an interview with as little as NUMBER_TOKEN hours notice and the best part you don't even have to pay until you get hired please check out the link in the description below for more details END_SPONSOR_TOKEN