-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinBinaryString.java
More file actions
32 lines (27 loc) · 907 Bytes
/
MinBinaryString.java
File metadata and controls
32 lines (27 loc) · 907 Bytes
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
/**
* Created by MalhotR1 on 05/09/2018.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class MinBinaryString {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int N = Integer.parseInt(br.readLine().trim());
char[] in = br.readLine().trim().toCharArray();
int one = 0;
for (int i = 0; i < in.length; i++) {
if (in[i] == '1') one++;
}
if (one == 0) System.out.println(0);
else {
int count = in.length - one;
System.out.print(1);
for (int i = 0; i < count; i++) {
System.out.print(0);
}
System.out.println();
}
}
}
}