Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 634 Bytes

Question_392.md

File metadata and controls

25 lines (21 loc) · 634 Bytes

LeetCode Records - Question 392 Is Subsequence

Attempt 1: Use two char arrays

class Solution {
    public boolean isSubsequence(String s, String t) {
        char[] sCharArr = s.toCharArray();
        char[] tCharArr = t.toCharArray();

        int sIndex = 0;
        int tIndex = 0;
        for (; sIndex < sCharArr.length && tIndex < tCharArr.length; tIndex++) {
            if (sCharArr[sIndex] == tCharArr[tIndex]) {
                sIndex++;
            }
        }

        return sIndex == sCharArr.length;
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 41.76 MB (Beats: 9.32%)