Simple Java solution


  • 0
    K

    int i,j;
    for (i=0,j=0;i<s.length()&&j<t.length();){
    if (s.charAt(i)==t.charAt(j)){
    i++;j++;
    }
    else j++;
    }
    return i==s.length()?true:false;


Log in to reply
 

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