-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3270.java
22 lines (21 loc) · 932 Bytes
/
_3270.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.fishercoder.solutions.fourththousand;
public class _3270 {
public static class Solution1 {
public int generateKey(int num1, int num2, int num3) {
String[] padded = new String[3];
padded[0] = String.format("%04d", num1);
padded[1] = String.format("%04d", num2);
padded[2] = String.format("%04d", num3);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < padded[0].length(); i++) {
sb.append(
Math.min(
Character.getNumericValue(padded[0].charAt(i)),
Math.min(
Character.getNumericValue(padded[1].charAt(i)),
Character.getNumericValue(padded[2].charAt(i)))));
}
return Integer.parseInt(sb.toString());
}
}
}