leetcode.com 2023-10-30
🟢1356.sort-integers-by-the-number-of-1-bits
🏷️ Tags
#bit_manipulation #array #counting #sorting
🟢1356.sort-integers-by-the-number-of-1-bits
🏷️ Tags
#bit_manipulation #array #counting #sorting
Telegraph
sort-integers-by-the-number-of-1-bits
You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order. Return the…
leetcode.cn 2023-10-31
🔴2003.smallest-missing-genetic-value-in-each-subtree
🏷️ Tags
#tree #depth_first_search #union_find #dynamic_programming
🔴2003.smallest-missing-genetic-value-in-each-subtree
🏷️ Tags
#tree #depth_first_search #union_find #dynamic_programming
Telegraph
smallest-missing-genetic-value-in-each-subtree
有一棵根节点为 0 的 家族树 ,总共包含 n 个节点,节点编号为 0 到 n - 1 。给你一个下标从 0 开始的整数数组 parents ,其中 parents[i] 是节点 i 的父节点。由于节点 0 是 根 ,所以 parents[0] == -1 。 总共有 105 个基因值,每个基因值都用 闭区间 [1, 105] 中的一个整数表示。给你一个下标从 0 开始的整数数组 nums ,其中 nums[i] 是节点 i 的基因值,且基因值 互不相同 。 请你返回一个数组 ans ,长度为 n ,其…
leetcode.cn 2023-11-01
🔴2127.maximum-employees-to-be-invited-to-a-meeting
🏷️ Tags
#depth_first_search #graph #topological_sort
🔴2127.maximum-employees-to-be-invited-to-a-meeting
🏷️ Tags
#depth_first_search #graph #topological_sort
Telegraph
maximum-employees-to-be-invited-to-a-meeting
一个公司准备组织一场会议,邀请名单上有 n 位员工。公司准备了一张 圆形 的桌子,可以坐下 任意数目 的员工。 员工编号为 0 到 n - 1 。每位员工都有一位 喜欢 的员工,每位员工 当且仅当 他被安排在喜欢员工的旁边,他才会参加会议。每位员工喜欢的员工 不会 是他自己。 给你一个下标从 0 开始的整数数组 favorite ,其中 favorite[i] 表示第 i 位员工喜欢的员工。请你返回参加会议的 最多员工数目 。 示例 1: 输入:favorite = [2,2,1,2] 输出:3 解释:…
leetcode.com 2023-11-01
🟢501.find-mode-in-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟢501.find-mode-in-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Telegraph
find-mode-in-binary-search-tree
Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it. If the tree has more than one mode, return them in any order. Assume a BST is defined as follows:
👍1
leetcode.com 2023-11-02
🟡2265.count-nodes-equal-to-average-of-subtree
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡2265.count-nodes-equal-to-average-of-subtree
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
count-nodes-equal-to-average-of-subtree
Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree. Note:
leetcode.cn 2023-11-03
🟡117.populating-next-right-pointers-in-each-node-ii
🏷️ Tags
#tree #depth_first_search #breadth_first_search #linked_list #binary_tree
🟡117.populating-next-right-pointers-in-each-node-ii
🏷️ Tags
#tree #depth_first_search #breadth_first_search #linked_list #binary_tree
Telegraph
populating-next-right-pointers-in-each-node-ii
给定一个二叉树: struct Node { int val; Node *left; Node *right; Node *next; } 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL 。 初始状态下,所有 next 指针都被设置为 NULL 。 示例 1: 输入:root = [1,2,3,4,5,null,7] 输出:[1,#,2,3,#,4,5,7,#] 解释:给定二叉树如图 A 所示,你的函数应该填充它的每个 next…
leetcode.cn 2023-11-04
🟡421.maximum-xor-of-two-numbers-in-an-array
🏷️ Tags
#bit_manipulation #trie #array #hash_table
🟡421.maximum-xor-of-two-numbers-in-an-array
🏷️ Tags
#bit_manipulation #trie #array #hash_table
Telegraph
maximum-xor-of-two-numbers-in-an-array
给你一个整数数组 nums ,返回 nums[i] XOR nums[j] 的最大运算结果,其中 0 ≤ i ≤ j < n 。 示例 1: 输入:nums = [3,10,5,25,2,8] 输出:28 解释:最大运算结果是 5 XOR 25 = 28. 示例 2: 输入:nums = [14,70,53,83,49,91,36,80,92,51,66,70] 输出:127 提示:
👍1
leetcode.com 2023-11-04
🟡1503.last-moment-before-all-ants-fall-out-of-a-plank
🏷️ Tags
#brainteaser #array #simulation
🟡1503.last-moment-before-all-ants-fall-out-of-a-plank
🏷️ Tags
#brainteaser #array #simulation
Telegraph
last-moment-before-all-ants-fall-out-of-a-plank
We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right. When two ants moving in two different directions meet at some…
leetcode.cn 2023-11-05
🟡187.repeated-dna-sequences
🏷️ Tags
#bit_manipulation #hash_table #string #sliding_window #hash_function #rolling_hash
🟡187.repeated-dna-sequences
🏷️ Tags
#bit_manipulation #hash_table #string #sliding_window #hash_function #rolling_hash
Telegraph
repeated-dna-sequences
DNA序列 由一系列核苷酸组成,缩写为 'A', 'C', 'G' 和 'T'.。
leetcode.cn 2023-11-09
🔴2258.escape-the-spreading-fire
🏷️ Tags
#breadth_first_search #array #binary_search #matrix
🔴2258.escape-the-spreading-fire
🏷️ Tags
#breadth_first_search #array #binary_search #matrix
Telegraph
escape-the-spreading-fire
给你一个下标从 0 开始大小为 m x n 的二维整数数组 grid ,它表示一个网格图。每个格子为下面 3 个值之一: