Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int search(String[] array, String token, int start, int end) {
- if(token.length() <= array[array.length/2].length()){ // I've put <= because it might be case as well
- if((token).equals(array[start])) return start;
- else{
- start++;
- if(start > array.length/2){
- System.out.println("Your Princess is in Another Castle START++");
- return -1;
- }
- return search(array, token, start, end);
- }
- }
- else
- {
- if((token).equals(array[end-1])) return end-1;
- end--;
- if(end < array.length/2){
- System.out.println("Your Princess is in Another Castle END--");
- return -1;
- }
- return search(array, token, start, end);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement