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

posted on 2017-05-13 11:32  Sempron2800+  阅读(102)  评论(0编辑  收藏  举报