-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberCard.java
More file actions
42 lines (37 loc) · 1.24 KB
/
Copy pathNumberCard.java
File metadata and controls
42 lines (37 loc) · 1.24 KB
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
41
42
package algorithm.baek.sort;
import algorithm.TestCase;
import java.io.*;
import java.text.ParseException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
public class NumberCard implements TestCase {
@Override
public void test() throws ParseException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st;
int tc = Integer.parseInt("6");
int[] arr = new int[tc];
int[] arr2 = new int[tc];
st = new StringTokenizer("1000 999 1000 999 1000 999");
for (int i = 0; i < tc; i++) {
int n = Integer.parseInt(st.nextToken());
arr[i] = n;
arr2[i] = n;
}
Arrays.sort(arr2);
int cnt = 0;
HashMap<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < tc; i++) {
if (map.get(arr2[i]) == null) {
map.put(arr2[i], cnt++);
}
}
for (int i = 0; i < tc; i++) {
bw.write(map.get(arr[i]) + " ");
}
bw.flush();
bw.close();
}
}