Kattis Challenge "Parking"
Problem
My solution
1import java.util.Scanner;
2public class Parking {
3 public static void main(String[] args) {
4 Scanner sc = new Scanner(System.in);
5 int t = sc.nextInt();
6 for (int i = 0; i < t; i++) {
7 int n = sc.nextInt();
8 int high = 0;
9 int low = 100;
10 int d = 0;
11 for (int j = 0; j < n; j++) {
12 int s = sc.nextInt();
13 if (s > high) {
14 high = s;
15 }
16 if (s < low) {
17 low = s;
18 }
19 d = (high - low) * 2;
20 }
21 System.out.println(d);
22 }
23 }
24}