Created
March 8, 2018 14:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String arg[]) { | |
Scanner sc = new Scanner(System.in); | |
int t = sc.nextInt(); | |
while (t-- > 0) { | |
int n = sc.nextInt(); | |
int max = -1, min = 100; | |
while (n-- > 0) { | |
int x = sc.nextInt(); | |
if (x > max) | |
max = x; | |
if (x < min) | |
min = x; | |
} | |
System.out.println("" + 2*(max - min)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment