标签:builder void build ddl 把数组排成最小的数 rgb adapter app eof
1 import java.util.ArrayList; 2 3 public class Solution { 4 public String PrintMinNumber(int [] numbers) { 5 if(numbers.length == 0) { 6 return ""; 7 } 8 adapter(numbers); 9 StringBuilder result = new StringBuilder(); 10 for(int i = 0; i < numbers.length; i ++) { 11 result.append(numbers[i]); 12 } 13 return result.toString(); 14 } 15 16 public int getMiddle(int[] data, int left, int right) { 17 int middle = data[left]; 18 while(left < right) { 19 while((left < right) && 20 (Long.valueOf(String.valueOf(middle) + String.valueOf(data[right])) <= Long.valueOf(String.valueOf(data[right]) + String.valueOf(middle)))) { 21 right --; 22 } 23 data[left] = data[right]; 24 while((left < right) && 25 (Long.valueOf(String.valueOf(middle) + String.valueOf(data[left])) >= Long.valueOf(String.valueOf(data[left]) + String.valueOf(middle)))) { 26 left ++; 27 } 28 data[right] = data[left]; 29 } 30 data[left] = middle; 31 return left; 32 } 33 34 public void quickSort(int[] data, int left, int right) { 35 if(left < right) { 36 int middle = getMiddle(data, left, right); 37 quickSort(data, left, middle - 1); 38 quickSort(data, middle + 1, right); 39 } 40 } 41 42 public void adapter(int[] data) { 43 quickSort(data, 0, data.length - 1); 44 } 45 }
标签:builder void build ddl 把数组排成最小的数 rgb adapter app eof
原文地址:https://www.cnblogs.com/StringBuilder/p/14757947.html