import java.util.Arrays;
public class MaxNumber {
public static long print(long number) {
return number
}
}
import java.util.LinkedList; import java.util.List; public class MaxNumber { public static long print(long numb) { long currentIntPart = numb; long currentDigit; List<Long> linkedList = new LinkedList<>(); for (int i = 0; currentIntPart > 0; i++) { currentDigit = currentIntPart % 10; currentIntPart = currentIntPart / 10; if (linkedList.isEmpty()) { linkedList.add(currentDigit); continue; } boolean inserted = false; for (int j = 0; j < linkedList.size(); j++){ if(currentDigit > linkedList.get(j)){ linkedList.add(j, currentDigit); inserted = true; break; } } if(!inserted) { linkedList.add(currentDigit); } } long result = 0; int count = 0; for (int i = linkedList.size() -1; i>=0; i--) { long digit = linkedList.get(i); result += digit * (long) Math.pow(10, count); count++; } return result; } }
import java.util.Arrays;- import java.util.LinkedList;
- import java.util.List;
- public class MaxNumber {
public static long print(long number) {return number- public static long print(long numb) {
- long currentIntPart = numb;
- long currentDigit;
- List<Long> linkedList = new LinkedList<>();
- for (int i = 0; currentIntPart > 0; i++) {
- currentDigit = currentIntPart % 10;
- currentIntPart = currentIntPart / 10;
- if (linkedList.isEmpty()) {
- linkedList.add(currentDigit);
- continue;
- }
- boolean inserted = false;
- for (int j = 0; j < linkedList.size(); j++){
- if(currentDigit > linkedList.get(j)){
- linkedList.add(j, currentDigit);
- inserted = true;
- break;
- }
- }
- if(!inserted) {
- linkedList.add(currentDigit);
- }
- }
- long result = 0;
- int count = 0;
- for (int i = linkedList.size() -1; i>=0; i--) {
- long digit = linkedList.get(i);
- result += digit * (long) Math.pow(10, count);
- count++;
- }
- return result;
- }
}- }