TreeviewCopyright © aleen42 all right reserved, powered by aleen42
1323. 6 和 9 组成的最大数字
Java
/*
* @Author: Goog Tech
* @Date: 2020-08-21 17:41:16
* @LastEditTime: 2020-08-21 17:41:59
* @Description: https://leetcode-cn.com/problems/maximum-69-number/
* @FilePath: \leetcode-googtech\#1323. Maximum 69 Number\Solution.java
* @WebSite: https://algorithm.show/
*/
class Solution {
public int maximum69Number (int num) {
return Integer.valueOf(String.valueOf(num).replaceFirst("6", "9"));
}
}
Python
'''
Author: Goog Tech
Date: 2020-08-21 17:41:24
LastEditTime: 2020-08-21 17:41:49
Description: https://leetcode-cn.com/problems/maximum-69-number/
FilePath: \leetcode-googtech\#1323. Maximum 69 Number\Solution.py
WebSite: https://algorithm.show/
'''
class Solution(object):
def maximum69Number (self, num):
"""
:type num: int
:rtype: int
"""
return int(str(num).replace("6", "9", 1))