Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.05 KB

_392. Is Subsequence.md

File metadata and controls

48 lines (33 loc) · 1.05 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 21, 2024

Last updated : June 21, 2024


Related Topics : Two Pointers, String, Dynamic Programming

Acceptance Rate : 48.034 %


Solutions

Java

class Solution {
    public boolean isSubsequence(String s, String t) {
        if (s.length() == 0)
            return true;

        int sPointer = 0;
        
        for (int tPointer = 0; tPointer < t.length(); tPointer++) {
            if (s.charAt(sPointer) == t.charAt(tPointer)) {
                sPointer++;

                if (sPointer >= s.length())
                    return true;    
            }
        }
        return false;
    }
}