public int longestZigZag(int[] sequence){
		if(sequence.length < 2) return sequence.length;
		int[] longestZigZag = new int[sequence.length];
		int[] arrivedFrom = new int[sequence.length];
		longestZigZag[0] = 1;
		for (int i = 1; i < longestZigZag.length; i++){
			longestZigZag[i] = 1;
			arrivedFrom[i] = i;
			System.out.println("jestem przy "+sequence[i]);
			for (int j = 0; j < i; j++) {
				System.out.print("spradzam "+sequence[j]+" i "+sequence[i] +"...");
				if (((j==0 && sequence[0] != sequence[1]) || (sequence[i] < sequence[j] == sequence[j] > sequence[arrivedFrom[j]] && sequence[j]!=sequence[i] && sequence[j] != sequence[arrivedFrom[j]])) && longestZigZag[j] + 1 > longestZigZag[i]) {
					longestZigZag[i] = longestZigZag[j] + 1;
					arrivedFrom[i] = j;
					System.out.println(" ok");
				}
				System.out.println();
			}
		}
		System.out.println(Arrays.toString(sequence));
		System.out.println(Arrays.toString(longestZigZag));
		System.out.println(Arrays.toString(arrivedFrom));
		return longestZigZag[longestZigZag.length - 1];
	}