https://leetcode.com/problems/maximum-value-of-a-string-in-an-array/description/
Maximum Value of a String in an Array - LeetCode
Maximum Value of a String in an Array - The value of an alphanumeric string can be defined as: * The numeric representation of the string in base 10, if it comprises of digits only. * The length of the string, otherwise. Given an array strs of alphanumeric
leetcode.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Solution:
def maximumValue(self, strs: List[str]) -> int:
answer = 0
for i in strs:
is_alpha = False
for character in i:
if character.isalpha():
is_alpha = True
if is_alpha:
answer = max(answer, len(i))
else:
answer = max(answer,int(i))
return answer
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2404. Most Frequent Even Element (0) | 2023.01.19 |
---|---|
leetcode 2465. Number of Distinct Averages (0) | 2023.01.19 |
leetcode 2535. Difference Between Element Sum and Digit Sum of an Array (0) | 2023.01.17 |
leetcode 326. Power of Three (0) | 2023.01.17 |
leetcode 263. Ugly Number (0) | 2023.01.17 |
댓글