Problem Solving/LeetCode

Today's Challenge

fabichoi 2022. 6. 27. 23:45

https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/

 

Partitioning Into Minimum Number Of Deci-Binary Numbers - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

엄청 간단하게 풂. (물론 효율은 하위 5%)
그냥 문제와 예를 잘 읽어보면, 전체 숫자 중에 가장 큰 값을 출력해주면 됨.

class Solution:
    def minPartitions(self, n: str) -> int:
        res = 0
        for nn in n:
            res = max(res, int(nn))
        return res

그냥 list(map) 써서 개선했더니 하위 30%로 올라감

class Solution:
    def minPartitions(self, n: str) -> int:        
        return max(list(map(int,n)))
반응형