leetcode.cn 2024-01-29
🔴514.freedom-trail
🏷️ Tags
#depth_first_search #breadth_first_search #string #dynamic_programming
🔴514.freedom-trail
🏷️ Tags
#depth_first_search #breadth_first_search #string #dynamic_programming
Telegraph
freedom-trail
电子游戏“辐射4”中,任务 “通向自由” 要求玩家到达名为 “Freedom Trail Ring” 的金属表盘,并使用表盘拼写特定关键词才能开门。 给定一个字符串 ring ,表示刻在外环上的编码;给定另一个字符串 key ,表示需要拼写的关键词。您需要算出能够拼写关键词中所有字符的最少步数。 最初,ring 的第一个字符与 12:00 方向对齐。您需要顺时针或逆时针旋转 ring 以使 key 的一个字符在 12:00 方向对齐,然后按下中心按钮,以此逐个拼写完 key 中的所有字符。 旋转 ring 拼出…
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…