class Solution {
public int largestInteger(int num) {
String s = ""+num;
char[] c = s.toCharArray();
int n = c.length;
LinkedList<Integer> odd = new LinkedList<>();
LinkedList<Integer> even = new LinkedList<>();
int cc = 0;
while(num != 0){
if((num % 10) % 2 == 0)
even.add(num % 10);
else
odd.add(num % 10);
cc++;
num /= 10;
}
Collections.sort(odd, Collections.reverseOrder());
Collections.sort(even, Collections.reverseOrder());
int i = 0;
int j = 0;
for(int ii = 0; ii < n; ii++) {
if((c[ii] - '0') % 2 == 0)
c[ii] =(char)('0' + even.removeFirst());
else
c[ii] =(char)('0' + odd.removeFirst());
}
return Integer.valueOf(String.valueOf(c));
}
}