leetcode.com 2024-01-02
🟡2610.convert-an-array-into-a-2d-array-with-conditions
🏷️ Tags
#array #hash_table
🟡2610.convert-an-array-into-a-2d-array-with-conditions
🏷️ Tags
#array #hash_table
Telegraph
convert-an-array-into-a-2d-array-with-conditions
You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions:
leetcode.cn 2024-01-03
🟡2487.remove-nodes-from-linked-list
🏷️ Tags
#stack #recursion #linked_list #monotonic_stack
🟡2487.remove-nodes-from-linked-list
🏷️ Tags
#stack #recursion #linked_list #monotonic_stack
Telegraph
remove-nodes-from-linked-list
给你一个链表的头节点 head 。 移除每个右侧有一个更大数值的节点。 返回修改后链表的头节点 head 。 示例 1: 输入:head = [5,2,13,3,8] 输出:[13,8] 解释:需要移除的节点是 5 ,2 和 3 。 - 节点 13 在节点 5 右侧。 - 节点 13 在节点 2 右侧。 - 节点 8 在节点 3 右侧。 示例 2: 输入:head = [1,1,1,1] 输出:[1,1,1,1] 解释:每个节点的值都是 1 ,所以没有需要移除的节点。 提示:
leetcode.cn 2024-01-04
🟡2397.maximum-rows-covered-by-columns
🏷️ Tags
#bit_manipulation #array #backtracking #enumeration #matrix
🟡2397.maximum-rows-covered-by-columns
🏷️ Tags
#bit_manipulation #array #backtracking #enumeration #matrix
Telegraph
maximum-rows-covered-by-columns
给你一个下标从 0 开始、大小为 m x n 的二进制矩阵 matrix ;另给你一个整数 numSelect,表示你必须从 matrix 中选择的 不同 列的数量。 如果一行中所有的 1 都被你选中的列所覆盖,则认为这一行被 覆盖 了。 形式上,假设 s = {c1, c2, ...., cnumSelect} 是你选择的列的集合。对于矩阵中的某一行 row ,如果满足下述条件,则认为这一行被集合 s 覆盖:
leetcode.com 2024-01-04
🟡2870.minimum-number-of-operations-to-make-array-empty
🏷️ Tags
#greedy #array #hash_table #counting
🟡2870.minimum-number-of-operations-to-make-array-empty
🏷️ Tags
#greedy #array #hash_table #counting
Telegraph
minimum-number-of-operations-to-make-array-empty
You are given a 0-indexed array nums consisting of positive integers. There are two types of operations that you can apply on the array any number of times:
leetcode.cn 2024-01-05
🔴1944.number-of-visible-people-in-a-queue
🏷️ Tags
#stack #array #monotonic_stack
🔴1944.number-of-visible-people-in-a-queue
🏷️ Tags
#stack #array #monotonic_stack
Telegraph
number-of-visible-people-in-a-queue
有 n 个人排成一个队列,从左到右 编号为 0 到 n - 1 。给你以一个整数数组 heights ,每个整数 互不相同,heights[i] 表示第 i 个人的高度。 一个人能 看到 他右边另一个人的条件是这两人之间的所有人都比他们两人 矮 。更正式的,第 i 个人能看到第 j 个人的条件是 i < j 且 min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1]) 。 请你返回一个长度为 n 的数…
leetcode.com 2024-01-05
🟡300.longest-increasing-subsequence
🏷️ Tags
#array #binary_search #dynamic_programming
🟡300.longest-increasing-subsequence
🏷️ Tags
#array #binary_search #dynamic_programming
Telegraph
longest-increasing-subsequence
Given an integer array nums, return the length of the longest strictly increasing subsequence. Example 1: Input: nums = [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Example 2:…
leetcode.cn 2024-01-06
🟡2807.insert-greatest-common-divisors-in-linked-list
🏷️ Tags
#linked_list #math #number_theory
🟡2807.insert-greatest-common-divisors-in-linked-list
🏷️ Tags
#linked_list #math #number_theory
Telegraph
insert-greatest-common-divisors-in-linked-list
给你一个链表的头 head ,每个结点包含一个整数值。 在相邻结点之间,请你插入一个新的结点,结点值为这两个相邻结点值的 最大公约数 。 请你返回插入之后的链表。 两个数的 最大公约数 是可以被两个数字整除的最大正整数。 示例 1: 输入:head = [18,6,10,3] 输出:[18,6,6,2,10,1,3] 解释:第一幅图是一开始的链表,第二幅图是插入新结点后的图(蓝色结点为新插入结点)。 - 18 和 6 的最大公约数为 6 ,插入第一和第二个结点之间。 - 6 和 10 的最大公约数为…
👍1
leetcode.com 2024-01-06
🔴1235.maximum-profit-in-job-scheduling
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1235.maximum-profit-in-job-scheduling
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
maximum-profit-in-job-scheduling
We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You're given the startTime, endTime and profit arrays, return the maximum profit you can take such that there are no two jobs in the…
leetcode.com 2024-01-08
🟢938.range-sum-of-bst
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟢938.range-sum-of-bst
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Telegraph
range-sum-of-bst
Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. Example 1: Input: root = [10,5,15,3,7,null,18], low = 7, high = 15 Output: 32 Explanation:…
leetcode.cn 2024-01-09
🟡2707.extra-characters-in-a-string
🏷️ Tags
#trie #array #hash_table #string #dynamic_programming
🟡2707.extra-characters-in-a-string
🏷️ Tags
#trie #array #hash_table #string #dynamic_programming
Telegraph
extra-characters-in-a-string
给你一个下标从 0 开始的字符串 s 和一个单词字典 dictionary 。你需要将 s 分割成若干个 互不重叠 的子字符串,每个子字符串都在 dictionary 中出现过。s 中可能会有一些 额外的字符 不在任何子字符串中。 请你采取最优策略分割 s ,使剩下的字符 最少 。 示例 1: 输入:s = "leetscode", dictionary = ["leet","code","leetcode"] 输出:1 解释:将 s 分成两个子字符串:下标从 0 到 3 的 "leet" 和下标从…
leetcode.cn 2024-01-10
🟢2696.minimum-string-length-after-removing-substrings
🏷️ Tags
#stack #string #simulation
🟢2696.minimum-string-length-after-removing-substrings
🏷️ Tags
#stack #string #simulation
Telegraph
minimum-string-length-after-removing-substrings
给你一个仅由 大写 英文字符组成的字符串 s 。 你可以对此字符串执行一些操作,在每一步操作中,你可以从 s 中删除 任一个 "AB" 或 "CD" 子字符串。 通过执行操作,删除所有 "AB" 和 "CD" 子串,返回可获得的最终字符串的 最小 可能长度。 注意,删除子串后,重新连接出的字符串可能会产生新的 "AB" 或 "CD" 子串。 示例 1: 输入:s = "ABFCACDB" 输出:2 解释:你可以执行下述操作: - 从 "ABFCACDB" 中删除子串 "AB",得到 s = "FCACDB"…
leetcode.com 2024-01-10
🟡2385.amount-of-time-for-binary-tree-to-be-infected
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡2385.amount-of-time-for-binary-tree-to-be-infected
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
amount-of-time-for-binary-tree-to-be-infected
You are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start. Each minute, a node becomes infected if:
leetcode.cn 2024-01-11
🟡2645.minimum-additions-to-make-valid-string
🏷️ Tags
#stack #greedy #string #dynamic_programming
🟡2645.minimum-additions-to-make-valid-string
🏷️ Tags
#stack #greedy #string #dynamic_programming
Telegraph
minimum-additions-to-make-valid-string
给你一个字符串 word ,你可以向其中任何位置插入 "a"、"b" 或 "c" 任意次,返回使 word 有效 需要插入的最少字母数。 如果字符串可以由 "abc" 串联多次得到,则认为该字符串 有效 。 示例 1: 输入:word = "b" 输出:2 解释:在 "b" 之前插入 "a" ,在 "b" 之后插入 "c" 可以得到有效字符串 "abc" 。 示例 2: 输入:word = "aaa" 输出:6 解释:在每个 "a" 之后依次插入 "b" 和 "c" 可以得到有效字符串 "abcabcabc"…