-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.java
More file actions
35 lines (34 loc) · 770 Bytes
/
Copy pathsolution.java
File metadata and controls
35 lines (34 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 392. Is Subsequence
// https://leetcode.com/problems/is-subsequence/
// Easy | Java | Accepted 2022-08-21
// Runtime 1 ms | Memory 41.8 MB
class Solution {
public boolean isSubsequence(String s, String t) {
if(s.length()==0&&t.length()>0)
{
return true;
}
if(s.length()>0&&t.length()==0)
{
return false;
}
int m = 0;
for(int i = 0; i<t.length(); i++)
{
if(m==s.length())
{
break;
}
if(t.charAt(i)==s.charAt(m))
{
m++;
}
}
System.out.println(m);
if(m==s.length())
{
return true;
}
return false;
}
}