File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ <h2 >1323. Maximum 69 Number</h2 ><h3 >Easy</h3 ><hr ><div ><p >Given a positive integer <code >num</code > consisting only of digits 6 and 9.</p >
2
+
3
+ <p >Return the maximum number you can get by changing <strong >at most</strong > one digit (6 becomes 9, and 9 becomes 6).</p >
4
+
5
+ <p >  ; </p >
6
+ <p ><strong >Example 1:</strong ></p >
7
+
8
+ <pre ><strong >Input:</strong > num = 9669
9
+ <strong >Output:</strong > 9969
10
+ <strong >Explanation:</strong >
11
+ Changing the first digit results in 6669.
12
+ Changing the second digit results in 9969.
13
+ Changing the third digit results in 9699.
14
+ Changing the fourth digit results in 9666.  ;
15
+ The maximum number is 9969.
16
+ </pre >
17
+
18
+ <p ><strong >Example 2:</strong ></p >
19
+
20
+ <pre ><strong >Input:</strong > num = 9996
21
+ <strong >Output:</strong > 9999
22
+ <strong >Explanation:</strong > Changing the last digit 6 to 9 results in the maximum number.</pre >
23
+
24
+ <p ><strong >Example 3:</strong ></p >
25
+
26
+ <pre ><strong >Input:</strong > num = 9999
27
+ <strong >Output:</strong > 9999
28
+ <strong >Explanation:</strong > It is better not to apply any change.</pre >
29
+
30
+ <p >  ; </p >
31
+ <p ><strong >Constraints:</strong ></p >
32
+
33
+ <ul >
34
+ <li><code>1 <= num <= 10^4</code></li>
35
+ <li><code>num</code>'s digits are 6 or 9.</li>
36
+ </ul ></div >
You can’t perform that action at this time.
0 commit comments