shrek.apple
BAN USERHow about this?
class CCID15259735 {
// ST [11:21] ET [11:30]
public static void q1(){
String S = "ABAAMA????MAZON????????";
String P = "AMAZON";
// String S ="?????";
// String P ="ABCD";
for(int i=0; i< S.length();i++){
int k = i;
char thisChar;
boolean isPinS = true;
for(int posInP = 0; posInP < P.length() && k < S.length(); posInP++){
thisChar = S.charAt(k);
if(thisChar == '?' || thisChar == P.charAt(posInP)){
k++;
continue;
}
isPinS = false;
break;
}
if(isPinS && (k-i) == P.length()){
System.out.println("Fill [i][" + i + "] till [k][" + k + "] of S = " + S.substring(i, k));
i = k; // Once matched then progress i to k.
}
}
}
}
How about this?
- shrek.apple January 25, 2013