본문 바로가기

자료구조,알고리즘

LeetCode-153 Find Minimum in Rotated Sorted Array 파이썬 풀이

 

LeetCode - The World's Leading Online Programming Learning Platform

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

문제 

int형 배열 nums가 오름차순으로 정렬되어있고 (1~n)번 회전하였습니다. 이때 nums의 가장 최솟값을 반환하는 문제입니다.

풀이

파이썬에선 역시 min()함수를 이용하여 쉽게 해결할 수 있습니다.   

class Solution:
    def findMin(self, nums: List[int]) -> int:
        return min(nums)