We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9cbb439 commit b19dc14Copy full SHA for b19dc14
problems/0392.判断子序列.md
@@ -140,8 +140,29 @@ public:
140
## 其他语言版本
141
142
143
-Java:
144
-
+Java:
+```
145
+class Solution {
146
+ public boolean isSubsequence(String s, String t) {
147
+ int length1 = s.length(); int length2 = t.length();
148
+ int[][] dp = new int[length1+1][length2+1];
149
+ for(int i = 1; i <= length1; i++){
150
+ for(int j = 1; j <= length2; j++){
151
+ if(s.charAt(i-1) == t.charAt(j-1)){
152
+ dp[i][j] = dp[i-1][j-1] + 1;
153
+ }else{
154
+ dp[i][j] = dp[i][j-1];
155
+ }
156
157
158
+ if(dp[length1][length2] == length1){
159
+ return true;
160
161
+ return false;
162
163
164
+}
165
166
167
Python:
168
```python
0 commit comments