-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlatLandSpace.java
36 lines (32 loc) · 1.01 KB
/
FlatLandSpace.java
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
/*
* compare non space station with other space stations
*
* and open the template in the editor.
*/
package hackerRank;
import java.util.Scanner;
public class FlatLandSpace {
public static void main(String args[]) {
int maxDisFromSpace = 0;
int minDisFromSpace = 0;
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int c[] = new int[m];
for (int c_i = 0; c_i < m; c_i++) {
c[c_i] = in.nextInt();
}
// for (int cityIndex = 0; cityIndex < n; cityIndex++) {
// for (int spaceIndex = 0; spaceIndex < c.length; spaceIndex++) {
// if (minDisFromSpace > c[spaceIndex] - cityIndex) {
// minDisFromSpace = Math.abs(c[spaceIndex] - cityIndex);
// }
// }
// System.out.println("min is :" + minDisFromSpace);
// if (maxDisFromSpace < minDisFromSpace) {
// maxDisFromSpace = minDisFromSpace;
// }
// }
System.out.println("Ressult is :" + maxDisFromSpace);
}
}