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 |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2843. Count Symmetric Integers (0) | 2024.01.05 |
---|---|
leetcode 2894. Divisible and Non-divisible Sums Difference (1) | 2024.01.05 |
leetcode 2643. Row With Maximum Ones (1) | 2024.01.02 |
leetcode 2788. Split Strings by Separator (1) | 2024.01.02 |
leetcode 2824. Count Pairs Whose Sum is Less than Target (1) | 2024.01.02 |
댓글