A. Gravity Flip 直接sort一下就ok了。貌似div.2的第一题都习惯于sort... B. Domino Effect 题意应该都能懂吧,求最后还竖立的个数。 因为题目说到两个L之间肯定有一个R,两个R直接就肯定会有个L,所以遍历一遍过去。找到L(非第一个),就找L后面的R,L和R之间肯定最后都是竖立。找到R,就往后面找L,判断两者之间的骨诺米牌个数的奇偶性,为奇数,则+
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n).
题目描述 Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O
添加链接描述 class Solution:def productExceptSelf(self, nums: List[int]) -> List[int]:# 构造第i个数的左右数组n = len(nums)left,right,res = [1]*n,[1]*n,[1]*nfor i in range(1,n):left[i] = nums[i-1]*left[i-1]for i in r