leetcode.cn 2023-09-04
🟡449.serialize-and-deserialize-bst
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #binary_search_tree #string #binary_tree
🟡449.serialize-and-deserialize-bst
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #binary_search_tree #string #binary_tree
Telegraph
serialize-and-deserialize-bst
序列化是将数据结构或对象转换为一系列位的过程,以便它可以存储在文件或内存缓冲区中,或通过网络连接链路传输,以便稍后在同一个或另一个计算机环境中重建。 设计一个算法来序列化和反序列化 二叉搜索树 。 对序列化/反序列化算法的工作方式没有限制。 您只需确保二叉搜索树可以序列化为字符串,并且可以将该字符串反序列化为最初的二叉搜索树。 编码的字符串应尽可能紧凑。 示例 1: 输入:root = [2,1,3] 输出:[2,1,3] 示例 2: 输入:root = [] 输出:[] 提示:
leetcode.cn 2023-09-05
🟢2605.form-smallest-number-from-two-digit-arrays
🏷️ Tags
#array #hash_table #enumeration
🟢2605.form-smallest-number-from-two-digit-arrays
🏷️ Tags
#array #hash_table #enumeration
Telegraph
form-smallest-number-from-two-digit-arrays
示例 1: 输入:nums1 = [4,1,3], nums2 = [5,7] 输出:15 解释:数字 15 的数位 1 在 nums1 中出现,数位 5 在 nums2 中出现。15 是我们能得到的最小数字。 示例 2: 输入:nums1 = [3,5,2,6], nums2 = [3,1,7] 输出:3 解释:数字 3 的数位 3 在两个数组中都出现了。 提示:
leetcode.cn 2023-09-06
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
lowest-common-ancestor-of-deepest-leaves
给你一个有根节点 root 的二叉树,返回它 最深的叶节点的最近公共祖先 。 回想一下:
leetcode.com 2023-09-10
🔴1359.count-all-valid-pickup-and-delivery-options
🏷️ Tags
#math #dynamic_programming #combinatorics
🔴1359.count-all-valid-pickup-and-delivery-options
🏷️ Tags
#math #dynamic_programming #combinatorics
Telegraph
count-all-valid-pickup-and-delivery-options
Given n orders, each order consist in pickup and delivery services. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). Since the answer may be too large, return it modulo 10^9 + 7. Example 1: Input:…
leetcode.com 2023-09-11
🟡1282.group-the-people-given-the-group-size-they-belong-to
🏷️ Tags
#array #hash_table
🟡1282.group-the-people-given-the-group-size-they-belong-to
🏷️ Tags
#array #hash_table
Telegraph
group-the-people-given-the-group-size-they-belong-to
There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1. You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1]…
leetcode.com 2023-09-12
🟡1647.minimum-deletions-to-make-character-frequencies-unique
🏷️ Tags
#greedy #hash_table #string #sorting
🟡1647.minimum-deletions-to-make-character-frequencies-unique
🏷️ Tags
#greedy #hash_table #string #sorting
Telegraph
minimum-deletions-to-make-character-frequencies-unique
A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The frequency of a character in a string is the number of times…
leetcode.cn 2023-09-13
🟡2596.check-knight-tour-configuration
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix #simulation
🟡2596.check-knight-tour-configuration
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix #simulation
Telegraph
check-knight-tour-configuration
骑士在一张 n x n 的棋盘上巡视。在有效的巡视方案中,骑士会从棋盘的 左上角 出发,并且访问棋盘上的每个格子 恰好一次 。 给你一个 n x n 的整数矩阵 grid ,由范围 [0, n * n - 1] 内的不同整数组成,其中 grid[row][col] 表示单元格 (row, col) 是骑士访问的第 grid[row][col] 个单元格。骑士的行动是从下标 0 开始的。 如果 grid 表示了骑士的有效巡视方案,返回 true;否则返回 false。 注意,骑士行动时可以垂直移动两个格子…