Problem solving with programming: Joining an array of numbers to form the biggest number
Joining an array of numbers to form the biggest number
Given an array numbers, we have to join them in such a way that it forms the biggest number.
For example consider the simple three element array [10,3,2], they can be joined in following ways
1032, 1023, 2103, 2310, 3102, 3210. Among these numbers 3210 is the biggest number.
To solve this problem we definitely have to sort the given numbers using some criteria to form the biggest number.
Considering the above example, if we simply sort them in descending order, the array becomes [10,3,2] which does not form the biggest number.
Read full article from Problem solving with programming: Joining an array of numbers to form the biggest number
No comments:
Post a Comment