leetcode.cn 2023-09-28
🔴2251.number-of-flowers-in-full-bloom
🏷️ Tags
#array #hash_table #binary_search #ordered_set #prefix_sum #sorting
🔴2251.number-of-flowers-in-full-bloom
🏷️ Tags
#array #hash_table #binary_search #ordered_set #prefix_sum #sorting
Telegraph
number-of-flowers-in-full-bloom
给你一个下标从 0 开始的二维整数数组 flowers ,其中 flowers[i] = [starti, endi] 表示第 i 朵花的 花期 从 starti 到 endi (都 包含)。同时给你一个下标从 0 开始大小为 n 的整数数组 people ,people[i] 是第 i 个人来看花的时间。 请你返回一个大小为 n 的整数数组 answer ,其中 answer[i]是第 i 个人到达时在花期内花的 数目 。 示例 1: 输入:flowers = [[1,6],[3,7],[9,12]…
leetcode.com 2023-09-30
🟡456.132-pattern
🏷️ Tags
#stack #array #binary_search #ordered_set #monotonic_stack
🟡456.132-pattern
🏷️ Tags
#stack #array #binary_search #ordered_set #monotonic_stack
Telegraph
132-pattern
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false. Example 1: Input:…
leetcode.cn 2023-10-02
🟡122.best-time-to-buy-and-sell-stock-ii
🏷️ Tags
#greedy #array #dynamic_programming
🟡122.best-time-to-buy-and-sell-stock-ii
🏷️ Tags
#greedy #array #dynamic_programming
Telegraph
best-time-to-buy-and-sell-stock-ii
给你一个整数数组 prices ,其中 prices[i] 表示某支股票第 i 天的价格。 在每一天,你可以决定是否购买和/或出售股票。你在任何时候 最多 只能持有 一股 股票。你也可以先购买,然后在 同一天 出售。 返回 你能获得的 最大 利润 。 示例 1: 输入:prices = [7,1,5,3,6,4] 输出:7 解释:在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5 - 1 = 4 。 随后,在第 4 天(股票价格…
leetcode.com 2023-10-02
🟡2038.remove-colored-pieces-if-both-neighbors-are-the-same-color
🏷️ Tags
#greedy #math #string #game_theory
🟡2038.remove-colored-pieces-if-both-neighbors-are-the-same-color
🏷️ Tags
#greedy #math #string #game_theory
Telegraph
remove-colored-pieces-if-both-neighbors-are-the-same-color
There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece. Alice and Bob are playing a game where they take alternating turns removing…
leetcode.cn 2023-10-05
🟡309.best-time-to-buy-and-sell-stock-with-cooldown
🏷️ Tags
#array #dynamic_programming
🟡309.best-time-to-buy-and-sell-stock-with-cooldown
🏷️ Tags
#array #dynamic_programming
Telegraph
best-time-to-buy-and-sell-stock-with-cooldown
给定一个整数数组prices,其中第 prices[i] 表示第 i 天的股票价格 。 设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票):
leetcode.cn 2023-10-06
🟡714.best-time-to-buy-and-sell-stock-with-transaction-fee
🏷️ Tags
#greedy #array #dynamic_programming
🟡714.best-time-to-buy-and-sell-stock-with-transaction-fee
🏷️ Tags
#greedy #array #dynamic_programming
Telegraph
best-time-to-buy-and-sell-stock-with-transaction-fee
给定一个整数数组 prices,其中 prices[i]表示第 i 天的股票价格 ;整数 fee 代表了交易股票的手续费用。 你可以无限次地完成交易,但是你每笔交易都需要付手续费。如果你已经购买了一个股票,在卖出它之前你就不能再继续购买股票了。 返回获得利润的最大值。 注意:这里的一笔交易指买入持有并卖出股票的整个过程,每笔交易你只需要为支付一次手续费。 示例 1: 输入:prices = [1, 3, 2, 8, 4, 9], fee = 2 输出:8 解释:能够达到的最大利润: 在此处买入 prices[0]…