Skip to content

Latest commit

 

History

History
 
 

isSubsequence

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

判断子序列

LeetCode地址

代码

class Solution {
    public boolean isSubsequence(String s, String t) {
        char[] arr = s.toCharArray();
        int j = -1;
        for (int i = 0; i < arr.length; i++) {
            j = t.indexOf(arr[i], j + 1);
            if (j == -1)
                return false;
        }
        return true;
    }
}