Given an array of integersContinue reading “[Leetcode problems]1477. Find Two Non-overlapping Sub-arrays Each With Target Sum”`arr`

and an integer`target`

. You have to findtwo non-overlapping sub-arraysof`arr`

each with sum equal`target`

. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays isminimum. Returnthe minimum sum of the lengthsof the two required sub-arrays, or returnif you cannot find such two sub-arrays.-1Example 1:Input:arr = [3,2,2,4,3], target = 3Output:2Explanation:Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.Example 2:Input:arr = [7,3,4,7], target = 7Output:2Explanation:Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.

## [Leetcode problems] 72. Edit Distance

Given two wordsContinue reading “[Leetcode problems] 72. Edit Distance”word1andword2, find the minimum number of operations required to convertword1toword2. You have the following 3 operations permitted on a word:Inserta characterDeletea characterReplacea characterExample: word1 = 'horse', word2 = 'ros' horse -> rorse (replace 'h' with 'r') rorse -> rose (remove 'r') rose -> ros (remove 'e')

## Depth-First-Search(DFS) vs Dynamic Programming(DP)

DFS is a searching algorithm that would go as far as possible before backtracking, and Dynamic Programming, referring to *GeeksforGeeks*, is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to avoid computing the same results again. What are connections do they share? Let me uncover this by a Leetcode problem: 494. Target Sum.