leetcode_打卡11

leetcode_打卡11

题目:392. 判断子序列

代码:

class Solution {
    public boolean isSubsequence(String s, String t) {
        int n = s.length(), m = t.length();
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (s.charAt(i) == t.charAt(j)) {
                i++;
            }
            j++;
        }
        return i == n;
    }
}


posted @ 2023-04-22 23:15  ZLey  阅读(10)  评论(0编辑  收藏  举报