首页 > 代码库 > leetcode392

leetcode392

public class Solution {
    public bool IsSubsequence(string s, string t) {
        var i = 0;
            var j = 0;
            while (i < s.Length && j < t.Length)
            {
                if (s[i] == t[j])
                {
                    i++;
                    j++;
                }
                else
                {
                    j++;
                }
            }

            if (i >= s.Length)
            {
                return true;
            }
            else
            {
                return false;
            }
    }
}

https://leetcode.com/problems/is-subsequence/#/description

leetcode392