Skip to content

Instantly share code, notes, and snippets.

@stephen-maina
Created April 14, 2015 07:32
Show Gist options
  • Save stephen-maina/2dc81d42ef2a7c9c116d to your computer and use it in GitHub Desktop.
Save stephen-maina/2dc81d42ef2a7c9c116d to your computer and use it in GitHub Desktop.
not fast enough
import java.util.Arrays;
import java.util.HashMap;
class Solution {
public int[] solution(String S, int[] P, int[] Q) {
// write your code in Java SE 8
int []result=new int[P.length];
for(int index=0;index<P.length;index++){
String check= S.substring(P[index],Q[index]+1);
if(check.contains("A")){
result[index]=1;
}else if(check.contains("C")){
result[index]=2;
}else if(check.contains("G")){
result[index]=3;
}else{
result[index]=4;
}
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment