1323. Maximum 69 Number Easy
1/**
2 * [1323] Maximum 69 Number
3 *
4 * You are given a positive integer num consisting only of digits 6 and 9.
5 * Return the maximum number you can get by changing at most one digit (6 becomes 9, and 9 becomes 6).
6 *
7 * Example 1:
8 *
9 * Input: num = 9669
10 * Output: 9969
11 * Explanation:
12 * Changing the first digit results in 6669.
13 * Changing the second digit results in 9969.
14 * Changing the third digit results in 9699.
15 * Changing the fourth digit results in 9666.
16 * The maximum number is 9969.
17 *
18 * Example 2:
19 *
20 * Input: num = 9996
21 * Output: 9999
22 * Explanation: Changing the last digit 6 to 9 results in the maximum number.
23 *
24 * Example 3:
25 *
26 * Input: num = 9999
27 * Output: 9999
28 * Explanation: It is better not to apply any change.
29 *
30 *
31 * Constraints:
32 *
33 * 1 <= num <= 10^4
34 * num consists of only 6 and 9 digits.
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/maximum-69-number/
40// discuss: https://leetcode.com/problems/maximum-69-number/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn maximum69_number (num: i32) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_1323() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.