Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 889 Bytes

File metadata and controls

46 lines (33 loc) · 889 Bytes

392. Question 392

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

Back to top


First completed : June 22, 2024

Last updated : June 22, 2024


Related Topics : N/A

Acceptance Rate : Unknown


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;
    }
}