leetcode.cn 2024-02-02
🟡1686.stone-game-vi
🏷️ Tags
#greedy #array #math #game_theory #sorting #heap_priority_queue
🟡1686.stone-game-vi
🏷️ Tags
#greedy #array #math #game_theory #sorting #heap_priority_queue
Telegraph
stone-game-vi
Alice 和 Bob 轮流玩一个游戏,Alice 先手。 一堆石子里总共有 n 个石子,轮到某个玩家时,他可以 移出 一个石子并得到这个石子的价值。Alice 和 Bob 对石子价值有 不一样的的评判标准 。双方都知道对方的评判标准。 给你两个长度为 n 的整数数组 aliceValues 和 bobValues 。aliceValues[i] 和 bobValues[i] 分别表示 Alice 和 Bob 认为第 i 个石子的价值。 所有石子都被取完后,得分较高的人为胜者。如果两个玩家得分相同,那么为平局。两位玩家都会采用…
leetcode.cn 2024-02-05
🟡1696.jump-game-vi
🏷️ Tags
#queue #array #dynamic_programming #monotonic_queue #heap_priority_queue
🟡1696.jump-game-vi
🏷️ Tags
#queue #array #dynamic_programming #monotonic_queue #heap_priority_queue
Telegraph
jump-game-vi
给你一个下标从 0 开始的整数数组 nums 和一个整数 k 。 一开始你在下标 0 处。每一步,你最多可以往前跳 k 步,但你不能跳出数组的边界。也就是说,你可以从下标 i 跳到 [i + 1, min(n - 1, i + k)] 包含 两个端点的任意位置。 你的目标是到达数组最后一个位置(下标为 n - 1 ),你的 得分 为经过的所有数字之和。 请你返回你能得到的 最大得分 。 示例 1: 输入:nums = [1,-1,-2,4,-7,3], k = 2 输出:7 解释:你可以选择子序列 [1…
leetcode.com 2024-02-05
🟢387.first-unique-character-in-a-string
🏷️ Tags
#queue #hash_table #string #counting
🟢387.first-unique-character-in-a-string
🏷️ Tags
#queue #hash_table #string #counting
Telegraph
first-unique-character-in-a-string
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Input: s = "leetcode" Output: 0 Example 2: Input: s = "loveleetcode" Output: 2 Example 3: Input: s = "aabb" Output: -1 Constraints:
👍5❤1
I’m preparing for a job change, so I’ve rewritten my script recently—Daily Leetcode Questions is BACK!
👍4
leetcode.cn 2025-02-21
🔴2209.minimum-white-tiles-after-covering-with-carpets
🏷️ Tags
#string #dynamic_programming #prefix_sum
🔴2209.minimum-white-tiles-after-covering-with-carpets
🏷️ Tags
#string #dynamic_programming #prefix_sum
Telegraph
minimum-white-tiles-after-covering-with-carpets
给你一个下标从 0 开始的 二进制 字符串 floor ,它表示地板上砖块的颜色。
leetcode.com 2025-02-21
🟡1261.find-elements-in-a-contaminated-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table #binary_tree
🟡1261.find-elements-in-a-contaminated-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table #binary_tree
Telegraph
find-elements-in-a-contaminated-binary-tree
Given a binary tree with the following rules:
leetcode.com 2025-02-22
🔴1028.recover-a-tree-from-preorder-traversal
🏷️ Tags
#tree #depth_first_search #string #binary_tree
🔴1028.recover-a-tree-from-preorder-traversal
🏷️ Tags
#tree #depth_first_search #string #binary_tree
Telegraph
recover-a-tree-from-preorder-traversal
We run a preorder depth-first search (DFS) on the root of a binary tree. At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. If the depth of a node is D, the depth of its immediate…
leetcode.cn 2025-02-22
🟢2506.count-pairs-of-similar-strings
🏷️ Tags
#bit_manipulation #array #hash_table #string #counting
🟢2506.count-pairs-of-similar-strings
🏷️ Tags
#bit_manipulation #array #hash_table #string #counting
Telegraph
count-pairs-of-similar-strings
给你一个下标从 0 开始的字符串数组 words 。 如果两个字符串由相同的字符组成,则认为这两个字符串 相似 。
leetcode.com 2025-02-23
🟡889.construct-binary-tree-from-preorder-and-postorder-traversal
🏷️ Tags
#tree #array #hash_table #divide_and_conquer #binary_tree
🟡889.construct-binary-tree-from-preorder-and-postorder-traversal
🏷️ Tags
#tree #array #hash_table #divide_and_conquer #binary_tree
Telegraph
construct-binary-tree-from-preorder-and-postorder-traversal
Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree. If there exist multiple answers…
leetcode.com 2025-02-24
🟡2467.most-profitable-path-in-a-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #graph #array
🟡2467.most-profitable-path-in-a-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #graph #array
Telegraph
most-profitable-path-in-a-tree
There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. At every node i, there…
leetcode.com 2025-02-25
🟡1524.number-of-sub-arrays-with-odd-sum
🏷️ Tags
#array #math #dynamic_programming #prefix_sum
🟡1524.number-of-sub-arrays-with-odd-sum
🏷️ Tags
#array #math #dynamic_programming #prefix_sum
Telegraph
number-of-sub-arrays-with-odd-sum
Given an array of integers arr, return the number of subarrays with an odd sum. Since the answer can be very large, return it modulo 109 + 7. Example 1: Input: arr = [1,3,5] Output: 4 Explanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]] All…