python-algorithm
leetcode 2974. Minimum Number Game
무적김두칠
2024. 1. 5. 14:57
https://leetcode.com/problems/minimum-number-game/description/
Minimum Number Game - LeetCode
Can you solve this real interview question? Minimum Number Game - You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. Th
leetcode.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class Solution: def numberGame(self, nums: List[int]) -> List[int]: answer = [] for i in range(len(nums)//2): num1 = min(nums) nums.remove(num1) num2 = min(nums) nums.remove(num2) answer.append(num2) answer.append(num1) return answer | cs |
반응형