【墨鳌】【判断子序列】

class Solution {
public:
    bool isSubsequence(string s, string t) {
        int n = s.length(), m = t.length();
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (s[i] == t[j]) {
                i++;
            }
            j++;
        }
        return i == n;
    }
};
posted @ 2022-03-08 19:42  墨鳌  阅读(17)  评论(0编辑  收藏  举报