forked from LeetCode-in-Net/LeetCode-in-Net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.cs
More file actions
28 lines (26 loc) · 756 Bytes
/
Solution.cs
File metadata and controls
28 lines (26 loc) · 756 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
namespace LeetCodeNet.G0301_0400.S0392_is_subsequence {
// #Easy #String #Dynamic_Programming #Two_Pointers #LeetCode_75_Two_Pointers
// #Dynamic_Programming_I_Day_19 #Level_1_Day_2_String #Udemy_Two_Pointers
// #Top_Interview_150_Two_Pointers #2025_07_18_Time_0_ms_(100.00%)_Space_41.56_MB_(66.80%)
public class Solution {
public bool IsSubsequence(string s, string t) {
int i = 0;
int j = 0;
int n = t.Length;
int m = s.Length;
if (m == 0) {
return true;
}
while (j < n) {
if (s[i] == t[j]) {
i++;
if (i == m) {
return true;
}
}
j++;
}
return false;
}
}
}