logo CodeStepByStep logo

largestNumber

Language/Type: C++ algorithms vector interview
Related Links:

Write a function named largestNumber that accepts a reference to a vector 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 vector passed is {11, 3}, you should return "311". If the vector passed is {2, 20, 7, 8, 25}, you should return "8725220". You may assume that the vector contains at least one element and that all values in the vector are greater than 0.

Function: Write a C++ function as described, not a complete program.

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.