leetcode.cn 2023-09-23
🟡1993.operations-on-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table
🟡1993.operations-on-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table
Telegraph
operations-on-tree
给你一棵 n 个节点的树,编号从 0 到 n - 1 ,以父节点数组 parent 的形式给出,其中 parent[i] 是第 i 个节点的父节点。树的根节点为 0 号节点,所以 parent[0] = -1 ,因为它没有父节点。你想要设计一个数据结构实现树里面对节点的加锁,解锁和升级操作。 数据结构需要支持如下函数:
leetcode.com 2023-09-23
🟡1048.longest-string-chain
🏷️ Tags
#array #hash_table #two_pointers #string #dynamic_programming
🟡1048.longest-string-chain
🏷️ Tags
#array #hash_table #two_pointers #string #dynamic_programming
Telegraph
longest-string-chain
You are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA without changing the order of the other characters to make it equal to…
leetcode.com 2023-09-25
🟢389.find-the-difference
🏷️ Tags
#bit_manipulation #hash_table #string #sorting
🟢389.find-the-difference
🏷️ Tags
#bit_manipulation #hash_table #string #sorting
Telegraph
find-the-difference
You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. Example 1: Input: s = "abcd", t = "abcde" Output: "e" Explanation: 'e' is the…
👍1
leetcode.cn 2023-09-27
🟡1333.filter-restaurants-by-vegan-friendly-price-and-distance
🏷️ Tags
#array #sorting
🟡1333.filter-restaurants-by-vegan-friendly-price-and-distance
🏷️ Tags
#array #sorting
Telegraph
filter-restaurants-by-vegan-friendly-price-and-distance
给你一个餐馆信息数组 restaurants,其中 restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]。你必须使用以下三个过滤器来过滤这些餐馆信息。 其中素食者友好过滤器 veganFriendly 的值可以为 true 或者 false,如果为 true 就意味着你应该只包括 veganFriendlyi 为 true 的餐馆,为 false 则意味着可以包括任何餐馆。此外,我们还有最大价格 maxPrice 和最大距…
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…