Skip to content

Instantly share code, notes, and snippets.

@0bach0
Last active February 16, 2020 15:52
Show Gist options
  • Select an option

  • Save 0bach0/88e06f5439dd485f9937f78c32d85b31 to your computer and use it in GitHub Desktop.

Select an option

Save 0bach0/88e06f5439dd485f9937f78c32d85b31 to your computer and use it in GitHub Desktop.

Revisions

  1. 0bach0 revised this gist Feb 16, 2020. No changes.
  2. 0bach0 created this gist Feb 16, 2020.
    20 changes: 20 additions & 0 deletions SubSequence.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    package jp.vietpro.vta;

    public class SubSequence {
    public static boolean isSubsequence(String s, String t) {
    if(s.length()==0)
    return true;
    int sI=0;

    for (int tI=0; tI < t.length(); tI++ ){
    if (t.charAt(tI) == s.charAt(sI)){
    sI++;
    }
    if(sI >= s.length()){
    return true;
    }
    }

    return false;
    }
    }