DESCRIPTION:
Task
Given an integer n, find the maximal number you can obtain by deleting exactly one digit of the given number.
Example
For n = 152, the output should be 52;
For n = 1001, the output should be 101.
Input/Output
- [input] integer n
- Constraints: 10 ≤ n ≤ 1000000.
- [output] an integer
def delete_digit(n):
print(n)
max=0
n=str(n)
for i in range(len(n)):
if max<=(numEx(n,i)):
max=numEx(n,i)
return max
def numEx(n,i):
return int(n[0:i]+n[i+1::])
'알고리즘 문제 > CodeWar' 카테고리의 다른 글
Autocomplete! Yay! (0) | 2022.11.06 |
---|---|
String Average (0) | 2022.11.04 |
Mean Square Error (0) | 2022.11.04 |
What century is it? (0) | 2022.11.04 |
Arrh, grabscrab! (0) | 2022.11.02 |