Problem Β· Math

Come Looking for the Smallest Num Which Must Be > Than a Specific Num. πŸ”Ž

Learn this problem
● EasyGeneral MotorsFULLTIMEOA

Problem statement

To solve this problem, you gonna need to write up the func in the editor πŸ‘‰

What you've been given: int Z

What your func is gonna do:

1. find the smallest num that is > than Z.

2. total of all the digits of the num you find must == 2 * (total of all digits of Z)

Memo πŸ“:

When solving this problem, you can mainly focus on correctness. As for your code performance, it would not be the focus this time πŸ˜‰.

Function

gmsFindTheTinestGreaterThanANum(N: int) β†’ int

Examples

Example 1

N = 10return = 11
As we can see, 11 is the smallest num that is > 10. What is the total sum of all digits of 10? The ans is 1 + 0 = 1... What is the total sum of all digits of 11? The ans is 1 + 1 = 2... 2 == 1 * 2, so 11 should be returned.

Example 2

N = 14return = 19
The total of all the digits of 19 (1 + 9 = 10) == 2 * total of digits of 14 (1 + 4 = 5)

Example 3

N = 99return = 9999
The sum of digits of 9999 (9 + 9 + 9 + 9 = 36) == total of digits of 99 (9 + 9 = 18).

Constraints

  • 1 <= Z <= 500.
  • More General Motors problems

    drafts saved locally
    public int gmsFindTheTinestGreaterThanANum(int Z) {
        // write your code here
    }
    
    N10
    expected11
    checking account