<awangdev>28. Implement strStr()_1.java
public int strStr(String haystack, String needle) {
        if (needle == null || needle.length() == 0) {
            return 0;
        }
        if (needle.length() > haystack.length()) {
            return -1;
        }
        int n = haystack.length();
        int m = needle.length();
        for (int i = 0; i < n; i++) { 
            if (n - i < m) {
                return -1;
            }
            if (haystack.charAt(i) != needle.charAt(0)) {
                continue;
            }
            
            if (haystack.substring(i, i + m).equals(needle)) { 
                return i;
            }
        }
        return -1;
    }
public int sample_funcname ( String var_1 , String var_2 ) {
  if ( var_2 == null || var_2 . length ( ) == 0 ) {
    return 0 ;
  }
  if ( var_2 . length ( ) > var_1 . length ( ) ) {
    return - 1 ;
  }
  int var_7 = var_1 . length ( ) ;
  int var_8 = var_2 . length ( ) ;
  for ( int var_9 = 0 ;
  var_9 < var_7 ;
  var_9 ++ ) {
    if ( var_7 - var_9 < var_8 ) {
      return - 1 ;
    }
    if ( var_1 . charAt ( var_9 ) != var_2 . charAt ( 0 ) ) {
      continue ;
    }
    if ( var_1 . substring ( var_9 , var_9 + var_8 ) . equals ( var_2 ) ) {
      return var_9 ;
    }
  }
  return - 1 ;
}
