leetcode1352. Product of the Last K Numbers
Intuition
后缀积。
用前缀积来做。特别注意 0
的情况,一旦有 0
,就不关心前面的数字,所以在处理零的时候,清空 vector
。
PS:有一种做法是在 vector
里放一个 1
方便计算。
Solution
时间复杂度:都是
Previousleetcode1351. Count Negative Numbers in a Sorted MatrixNextleetcode1353. Maximum Number of Events That Can Be Attended
Last updated