Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

//Jolly Jumpers Solution import java.util.HashMap; import java.util.Map; import java.util.

Scanner; public class JollyJumpers { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNextLine()){ Scanner line = new Scanner(in.nextLine()); int numNums = line.nextInt(); int[] numbers = new int[numNums]; Map<Integer, Boolean> seenIt = new HashMap<Integer, Boolean>(); for(int n = 1; n <= numNums; n++){ numbers[n - 1] = line.nextInt(); seenIt.put((n), false); } seenIt.remove((numNums)); for (int n = 1; n < numNums; n++){ int diff = Math.abs(numbers[n - 1] numbers[n]); seenIt.put(diff, true); } boolean flag = false; for(int n = 1; n < numNums; n++){ if(seenIt.get(n) == false){ System.out.println("Not Jolly"); flag = true; break; } } if(flag == false){ System.out.println("Jolly"); } System.out.println(seenIt.toString()); } } }

You might also like