less than 1 minute read

You are given an integer n consisting of digits 1, 2, and 3 and you can flip one digit to a 3. Return the maximum number you can make.

Constraints

  • 1 ≤ n < 2 ** 31

https://binarysearch.com/problems/123-Number-Flip

Examples

Example 1

Input

  • n = 123

Output

  • answer = 323

Explanation

We flip 1 to 3

Example 2

Input

  • n = 333

Output

  • answer = 333

Explanation

Flipping doesn’t help.

Solution

Leave a comment