본문 바로가기
python-algorithm

leetcode 3038. Maximum Number of Operations With the Same Score I

by 무적김두칠 2024. 2. 18.

https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/description/

 

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

 

1
2
3
4
5
6
7
8
9
10
11
class Solution:
    def maxOperations(self, nums: List[int]) -> int:
        first_two = nums[0+ nums[1]
        answer = 1
        for i in range(1len(nums)//2):
            if nums[i*2+ nums[i*2 + 1== first_two:
                answer +=1
            else:
                break
        return answer
 
cs

앞에 두개의 합을 계속 비교해나가면 됩니다

반응형

댓글