-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeautifulYear.java
More file actions
43 lines (38 loc) · 1.07 KB
/
BeautifulYear.java
File metadata and controls
43 lines (38 loc) · 1.07 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
43
/**
* Created by malhotr1 on 2/13/2017.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
public class BeautifulYear {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine().trim());
int year = T;
int[] dig = new int[4];
for (int i = year+1; i < Integer.MAX_VALUE; i++) {
boolean dis = true;
findDigits(dig, i);
Arrays.sort(dig);
for (int j = 0; j < 3; j++) {
if (dig[j] == dig[j+1]) {
dis = false;
break;
}
}
if (dis) {
System.out.println(i);
return;
}
}
}
private static void findDigits(int[] dig, int year) {
int i = 1;
while (year > 0) {
dig[4 - i] = year % 10;
year /= 10;
i++;
}
}
}