Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimum-sum-of-four-digit-number-after-splitting-digits #75

Open
ishita3513 opened this issue Oct 15, 2023 · 2 comments
Open

minimum-sum-of-four-digit-number-after-splitting-digits #75

ishita3513 opened this issue Oct 15, 2023 · 2 comments
Labels
Easy hactoberfest question Further information is requested

Comments

@ishita3513
Copy link
Contributor

You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.

For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].
Return the minimum possible sum of new1 and new2.

Example 1:

Input: num = 2932
Output: 52
Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
Example 2:

Input: num = 4009
Output: 13
Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc.
The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.

Constraints:

1000 <= num <= 9999

@ishita3513
Copy link
Contributor Author

Hey @Nikhil-2002 please assign this issue to me. I am interested in sharing my approach to solve this issue.

@Nikhil-2002 Nikhil-2002 added question Further information is requested hactoberfest Easy labels Oct 15, 2023
@ishita3513
Copy link
Contributor Author

ishita3513 commented Oct 15, 2023

Hey @Nikhil-2002 I solved issue #75. I have added the pull request. Please verify the proposed solution and merge it.
I have added two solutions to this problem. I have commented on the solution and time complexity as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy hactoberfest question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants