# [Daily programming] largest number-give a set of nonnegative integers to find the maximum numbers that can be spliced out of these nonnegative integers

Source: Internet
Author: User

English: Given A list of non negative integers, arrange them such that they form the largest number.

English: Give a set of nonnegative integers to find the maximum number of non-negative integers that can be spliced out

Description: For example, give an array of [3, 30, 34, 5, 9], the maximum number of stitching out is 9534330

`The correct sorting method is to compare two strings (set to A and b) in sequential order using the Sort method, and two strings a+b and B+a, if the a+b is larger, then A is in front b after, otherwise A is in front B.Public classSolution { Public StaticString Largestnumber (int[] nums) {string[] array=NewString[nums.length];  for(inti = 0; i < nums.length; i++) {Array[i]=string.valueof (Nums[i]);        } String temp;  for(inti = 0; i < Array.Length; i++)        {             for(intj = i+1; J < Array.Length; J + +)            {                if((Array[i] + array[j]). CompareTo (Array[j] + array[i]) < 0) {Temp=Array[i]; Array[i]=Array[j]; ARRAY[J]=temp; }            }        }                if(Array[0].equals ("0"))            return"0"; Else        {            returnString.Join ("", array); }    }             Public Static voidMain (string[] args) {int[] Nums = {3, 30, 34, 5, 9}; String Largestnum=Largestnumber (nums);    System.out.println (Largestnum); }}`

[Daily programming] largest number-give a set of nonnegative integers to find the maximum numbers that can be spliced out of these nonnegative integers

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.