Problem
My solution
1import java.util.ArrayList;
2import java.util.Scanner;
3
4public class KattisA {
5
6 public static void main(String[] args) {
7
8 Scanner sc = new Scanner(System.in);
9 int N = sc.nextInt();
10
11 boolean incr = false;
12 boolean decr = false;
13
14 ArrayList<String> al = new ArrayList();
15
16 for (int i = 0; i <= N; i++) {
17 al.add(sc.nextLine());
18 }
19
20 for (int i = 1; i < al.size() - 1; i++) {
21
22 //Increasing
23 if (al.get(i).charAt(0) < al.get(i + 1).charAt(0)) {
24 incr = true;
25 }
26 //Decreasing
27 if (al.get(i).charAt(0) > al.get(i + 1).charAt(0)) {
28 decr = true;
29 }
30
31 //If the first characters are equal, check the next character
32 if (al.get(i).charAt(0) == al.get(i + 1).charAt(0)) {
33 //Increasing
34 if (al.get(i).charAt(1) < al.get(i + 1).charAt(1)) {
35 incr = true;
36 }
37 //Decreasing
38 if (al.get(i).charAt(1) > al.get(i + 1).charAt(1)) {
39 decr = true;
40 }
41 }
42
43 }
44
45 if (decr && !incr) {
46 System.out.println("DECREASING");
47 } else if (!decr && incr) {
48 System.out.println("INCREASING");
49 } else if ((incr && decr) || (!incr & !decr)) {
50 System.out.println("NEITHER");
51 }
52
53 }
54}