java solution


  • 0
    2
    public class Solution {
        public boolean isSubsequence(String s, String t) {
            if (s.equals("")) return true;
            for (int i = 0, j = 0; j < t.length(); j++) {
                if (s.charAt(i) == t.charAt(j)) i++;
                if (i == s.length()) return true;
            }
            return false;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.