본문 바로가기

2024/09/213

3194. Minimum Average of Smallest and Largest Elements https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements/description/12345678910class Solution:    def minimumAverage(self, nums: List[int]) -> float:        nums.sort()        averages = []        for i in range(len(nums)//2):            averages.append((nums[i] + nums[-(i+1)])/2)                return min(averages)         Colored by Color Scriptercs 2024. 9. 21.
3232. Find if Digit Game Can Be Won https://leetcode.com/problems/find-if-digit-game-can-be-won/description/ 1234567891011121314class Solution:    def canAliceWin(self, nums: List[int]) -> bool:        sum_single, sum_double = 0, 0        for num in nums:            if num  10 :                sum_single += num            else:                sum_double += num         if sum_single == sum_double:            return False        els.. 2024. 9. 21.
3285. Find Indices of Stable Mountains https://leetcode.com/problems/find-indices-of-stable-mountains/description/ 12345678class Solution:    def stableMountains(self, height: List[int], threshold: int) -> List[int]:        answer = []        for i in range(1, len(height)):            if height[i - 1] > threshold:                answer.append(i)                return answerColored by Color Scriptercsheight 리스트를 순차 탐색하면서 바로 직전 값이 thre.. 2024. 9. 21.