logo CodeStepByStep logo

LargestNumber

Language/Type: C# algorithms arrays interview

Write a method named LargestNumber that accepts an array of positive integers as a parameter and returns a string representing the largest integer value that could be formed by concatenating together those integers. (We use a string since the result might be larger than the domain of type int or long.) For example, if the array passed is {11, 3}, you should return "311". If the array passed is {2, 20, 7, 8, 25}, you should return "8725220". You may assume that the array contains at least one element and that all values in the array are greater than 0.

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.