首页 > TAG信息列表 > 1475

Leetcode 1475.商品折扣后的最终价格

1475. 商品折扣后的最终价格难度简单 166     给你一个数组 prices ,其中 prices[i] 是商店里第 i 件商品的价格。 商店里正在进行促销活动,如果你要买第 i 件商品,那么你可以得到与 prices[j] 相等的折扣,其中 j 是满足 j > i 且 prices[j] <= prices[i] 的 最小下

1475. 商品折扣后的最终价格

1475. 商品折扣后的最终价格 给你一个数组 prices ,其中 prices[i] 是商店里第 i 件商品的价格。 商店里正在进行促销活动,如果你要买第 i 件商品,那么你可以得到与 prices[j] 相等的折扣,其中 j 是满足 j > i 且 prices[j] <= prices[i] 的 最小下标 ,如果没有满足

一本通 1475:L语言

一本通 1475:L语言 原题链接 Solution AC自动机 这题一眼看上去就是道 \(AC\) 自动机题。 于是快速地把 \(AC\) 自动机板子打出来,并建好 \(trie\) 图。 接下来分析一下题目 我们用 \(vis[i]\) 标记一段文章长度为 \(i\) 的前缀是否可以被表示出来。 对于一段文章,我们枚举它的前缀,设

【leetcode_easy】1475. Final Prices With a Special Discount in a Shop

leetcode_easy_array problem 1475. Final Prices With a Special Discount in a Shop solution #1: 使用新数组更新数据; code   solution #2: 直接在原数组更新数据; code:   注意: 1. 满足更新数据的边界条件是大于等于; 2. 更新后的结果是打折后的数据;   参考 1. leetcode_147

【SSL 1475】俄罗斯套娃

题目大意: 求长度为 \(n\) 的排列,逆序对个数小于等于 \(k\) 的排列个数。 正文: 设 \(f_{i,j}\) 表示前 \(i\) 位有 \(j\) 个逆序对的方案数,由于第 \(i\) 位能为前 \(i-1\) 位贡献,动态转移方程是: \[f_{i,j}=\sum_{l=0}^{i-1}f_{i-1,j-l} \]但这个时间复杂度是 \(O(nk^2)\),我们要开一

leetcode-1475-商品折扣后的最终价格

题目描述:        提交: class Solution: def finalPrices(self, prices: List[int]) -> List[int]: res = [] for i in range(len(prices)): for j in range(i,len(prices)): if j > i and prices[j] <= prices[i]:

1475. Final Prices With a Special Discount in a Shop

package LeetCode_1475 import java.util.* /** * 1475. Final Prices With a Special Discount in a Shop * https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/description/ * * Given the array prices where prices[i] is the price o