-
Notifications
You must be signed in to change notification settings - Fork 2
/
Day 14 Scope.cs
40 lines (30 loc) · 1006 Bytes
/
Day 14 Scope.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Linq;
class Difference {
private int[] elements;
public int maximumDifference;
// Add your code here
public Difference(int[] element){
this.elements = element;
}
public int computeDifference(){
for(int i = 0; i < elements.Length - 1; i++){
for(int j = 0; j < elements.Length; j++){
int difference = Math.Abs(elements[i] - elements[j]);
if(difference > maximumDifference){
maximumDifference = difference;
}
}
}
return maximumDifference;
}
} // End of Difference Class
class Solution {
static void Main(string[] args) {
Convert.ToInt32(Console.ReadLine());
int[] a = Console.ReadLine().Split(' ').Select(x=>Convert.ToInt32(x)).ToArray();
Difference d = new Difference(a);
d.computeDifference();
Console.Write(d.maximumDifference);
}
}