chaitutvk25
BAN USERpublic boolean checkConcatenations(String S){
boolean isStringConcatenationsOfStrings = false;
HashSet<String> dictionary = new HashSet<String>();
dictionary.add("world");
dictionary.add("hello");
dictionary.add("super");
dictionary.add("hell");
ArrayList<String> foundMatch = new ArrayList<String>();
int stringLength = S.length();
String subString = "";
for ( int index = 0 ; index < stringLength; index++){
subString += S.charAt(index);
int lenOfArray = foundMatch.size();
if ( lenOfArray > 0){
if(dictionary.contains(subString)){
foundMatch.add(subString);
subString = "";
}
String temp = subString;
for (int j = lenOfArray-1; j >= 0 && subString != "" ; j--){
temp = foundMatch.get(j) + temp;
if (dictionary.contains(temp)){
foundMatch.add(subString);
subString = "";
}
}
}
else if (dictionary.contains(subString)){
foundMatch.add(subString);
subString = "";
}
}
String result = "";
for (int index = 0; index < foundMatch.size(); index++){
result += foundMatch.get(index);
}
if (result.equals(S)){
isStringConcatenationsOfStrings = true;
}
return isStringConcatenationsOfStrings;
}
This solution definitely works, but as @Asonibare pointed out, it works for scores that increment by 1.
Again, the question is not clear if scores can increment in a range, that is if score increase can vary between certain values.
But if you think scores can increase by 2 or greater, then the maximum number of leads would be
Here is my algorithm to check if the scores can increment variably within a given range.
This will give me the maximum number of lead changes possible
- chaitutvk25 November 13, 2014