python-algorithm
leetcode 2496. Maximum Value of a String in an Array
무적김두칠
2023. 1. 19. 12:54
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 |
반응형