https://practice.geeksforgeeks.org/problems/min-sum-formed-by-digits/0
How to Approach this Question.
https://practice.geeksforgeeks.org/problems/min-sum-formed-by-digits/0
How to Approach this Question.
Hey Monika
This question can be solved by sorting the array elements and forming 2 separate numbers from alternate digits:
For example:
1,2,3,4,5
First number can be formed by using digits at even position: 135
second number can be formed by using digits at odd position: 24
The sum is 159, if you see it is the minimum possible case.
We are doing this because minimum numbers can be formed if we place minimum element at rightmost place in the number
If you use inbuilt sort to sort the elements then complexity would be O(nlogn) but if you use counting sort the complexity would be O(n)
I hope I was clear with the explanation?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.