Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package garbage;
- public class Garbage {
- public static void main(String[] args) {
- int[] array = {1, 1, 8, 5, 3, 7, 4, 3, 2, 4, 7, 3, 5, 9, 0};
- int result = 0;
- int number;
- int first;
- int last;
- for (int i=0; i<array.length-2; i++){
- for (int j=array.length-1; j>i; j--){
- number = 0;
- first = i;
- last = j;
- while (first<array.length && last>=0 && array[first]==array[last]){
- number++;
- first++;
- last--;
- }
- if (number>result){
- result = number;
- }
- }
- }
- System.out.println("Result: " + result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement