You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Given two </b>sequences `s1` and `s2`, write a method to find the length of the shortest sequence which has `s1` and `s2` as <b>subsequences</b>.
5065
+
> Given two <b>sequences</b>`s1` and `s2`, write a method to find the length of the shortest sequence which has `s1` and `s2` as <b>subsequences</b>.
5066
5066
5067
5067
#### Example 1:
5068
5068
```js
@@ -5110,9 +5110,6 @@ function findSCSLength(s1, s2) {
5110
5110
returnMath.min(length1, length2)
5111
5111
}
5112
5112
5113
-
5114
-
5115
-
5116
5113
returnfindSCSLengthRecursive(s1, s2, 0, 0) ;
5117
5114
};
5118
5115
@@ -5196,12 +5193,12 @@ console.log(
5196
5193
### Bottom-up Dynamic Programming
5197
5194
Since we want to match all the <b>subsequences</b> of the given <b>sequences</b>, we can use a two-dimensional array to store our results. The lengths of the two strings will define the size of the array’s dimensions. So for every index `i` in sequence `s1` and `j` in sequence `s2`, we will choose one of the following two options:
5198
5195
5199
-
1. If the character `s1[i]` matches `s2[j]`, the length of the <b>SCS<b> would be the one plus the length of the <b>SCS<b> until `i-1` and `j-1` indexes in the two strings.
5200
-
2. If the character `s1[i]` does not match `s2[j]`, we will consider two <b>SCS<b>:
5196
+
1. If the character `s1[i]` matches `s2[j]`, the length of the <b>SCS</b> would be the one plus the length of the <b>SCS</b> until `i-1` and `j-1` indexes in the two strings.
5197
+
2. If the character `s1[i]` does not match `s2[j]`, we will consider two <b>SCS</b>:
5201
5198
- one without `s1[i]` and one without `s2[j]`.
5202
-
- Our required <b>SCS<b> length will be the shortest of these two super-sequences plus one.
5199
+
- Our required <b>SCS</b> length will be the shortest of these two super-sequences plus one.
0 commit comments