leetcode.cn 2023-05-13
🟢2441.largest-positive-integer-that-exists-with-its-negative
🏷️ Tags
#array #hash_table #two_pointers #sorting
🟢2441.largest-positive-integer-that-exists-with-its-negative
🏷️ Tags
#array #hash_table #two_pointers #sorting
Telegraph
largest-positive-integer-that-exists-with-its-negative
给你一个 不包含 任何零的整数数组 nums ,找出自身与对应的负数都在数组中存在的最大正整数 k 。 返回正整数 k ,如果不存在这样的整数,返回 -1 。 示例 1: 输入:nums = [-1,2,-3,3] 输出:3 解释:3 是数组中唯一一个满足题目要求的 k 。 示例 2: 输入:nums = [-1,10,6,7,-7,1] 输出:7 解释:数组中存在 1 和 7 对应的负数,7 的值更大。 示例 3: 输入:nums = [-10,8,6,7,-2,-3] 输出:-1 解释:不存在满足题目要求的…
leetcode.cn 2023-05-14
🟡1054.distant-barcodes
🏷️ Tags
#greedy #array #hash_table #counting #sorting #heap_priority_queue
🟡1054.distant-barcodes
🏷️ Tags
#greedy #array #hash_table #counting #sorting #heap_priority_queue
Telegraph
distant-barcodes
在一个仓库里,有一排条形码,其中第 i 个条形码为 barcodes[i]。 请你重新排列这些条形码,使其中任意两个相邻的条形码不能相等。 你可以返回任何满足该要求的答案,此题保证存在答案。 示例 1: 输入:barcodes = [1,1,1,2,2,2] 输出:[2,1,2,1,2,1] 示例 2: 输入:barcodes = [1,1,1,1,2,2,3,3] 输出:[1,3,1,3,2,1,2,1] 提示:
leetcode.com 2023-05-14
🔴1799.maximize-score-after-n-operations
🏷️ Tags
#bit_manipulation #array #math #dynamic_programming #backtracking #bitmask #number_theory
🔴1799.maximize-score-after-n-operations
🏷️ Tags
#bit_manipulation #array #math #dynamic_programming #backtracking #bitmask #number_theory
Telegraph
maximize-score-after-n-operations
You are given nums, an array of positive integers of size 2 * n. You must perform n operations on this array. In the ith operation (1-indexed), you will:
leetcode.cn 2023-05-15
🟡1072.flip-columns-for-maximum-number-of-equal-rows
🏷️ Tags
#array #hash_table #matrix
🟡1072.flip-columns-for-maximum-number-of-equal-rows
🏷️ Tags
#array #hash_table #matrix
Telegraph
flip-columns-for-maximum-number-of-equal-rows
给定 m x n 矩阵 matrix 。 你可以从中选出任意数量的列并翻转其上的 每个 单元格。(即翻转后,单元格的值从 0 变成 1,或者从 1 变为 0 。) 返回 经过一些翻转后,行与行之间所有值都相等的最大行数 。 示例 1: 输入:matrix = [[0,1],[1,1]] 输出:1 解释:不进行翻转,有 1 行所有值都相等。 示例 2: 输入:matrix = [[0,1],[1,0]] 输出:2 解释:翻转第一列的值之后,这两行都由相等的值组成。 示例 3: 输入:matrix = [[0…
leetcode.com 2023-05-17
🟡2130.maximum-twin-sum-of-a-linked-list
🏷️ Tags
#stack #linked_list #two_pointers
🟡2130.maximum-twin-sum-of-a-linked-list
🏷️ Tags
#stack #linked_list #two_pointers
Telegraph
maximum-twin-sum-of-a-linked-list
In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.
leetcode.cn 2023-05-19
🟡1079.letter-tile-possibilities
🏷️ Tags
#hash_table #string #backtracking #counting
🟡1079.letter-tile-possibilities
🏷️ Tags
#hash_table #string #backtracking #counting
Telegraph
letter-tile-possibilities
你有一套活字字模 tiles,其中每个字模上都刻有一个字母 tiles[i]。返回你可以印出的非空字母序列的数目。 注意:本题中,每个活字字模只能使用一次。 示例 1: 输入:"AAB" 输出:8 解释:可能的序列为 "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA"。 示例 2: 输入:"AAABBC" 输出:188 示例 3: 输入:"V" 输出:1 提示:
leetcode.com 2023-05-19
🟡785.is-graph-bipartite
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡785.is-graph-bipartite
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
is-graph-bipartite
There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge…
leetcode.cn 2023-05-20
🔴1373.maximum-sum-bst-in-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #dynamic_programming #binary_tree
🔴1373.maximum-sum-bst-in-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #dynamic_programming #binary_tree
Telegraph
maximum-sum-bst-in-binary-tree
给你一棵以 root 为根的 二叉树 ,请你返回 任意 二叉搜索子树的最大键值和。 二叉搜索树的定义如下:
leetcode.com 2023-05-20
🟡399.evaluate-division
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #shortest_path
🟡399.evaluate-division
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #shortest_path
Telegraph
evaluate-division
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is a string that represents a single variable. You are also given…
leetcode.com 2023-05-21
🟡934.shortest-bridge
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix
🟡934.shortest-bridge
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix
Telegraph
shortest-bridge
You are given an n x n binary matrix grid where 1 represents land and 0 represents water. An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid. You may change 0's to 1's to connect the…
leetcode.cn 2023-05-22
🟡1080.insufficient-nodes-in-root-to-leaf-paths
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡1080.insufficient-nodes-in-root-to-leaf-paths
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
insufficient-nodes-in-root-to-leaf-paths
给你二叉树的根节点 root 和一个整数 limit ,请你同时删除树中所有 不足节点 ,并返回最终二叉树的根节点。 假如通过节点 node 的每种可能的 “根-叶” 路径上值的总和全都小于给定的 limit,则该节点被称之为 不足节点 ,需要被删除。 叶子节点,就是没有子节点的节点。 示例 1: 输入:root = [1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14], limit = 1 输出:[1,2,3,4,null,null,7,8,9,null,14]…
leetcode.com 2023-05-22
🟡347.top-k-frequent-elements
🏷️ Tags
#array #hash_table #divide_and_conquer #bucket_sort #counting #quickselect #sorting #heap_priority_queue
🟡347.top-k-frequent-elements
🏷️ Tags
#array #hash_table #divide_and_conquer #bucket_sort #counting #quickselect #sorting #heap_priority_queue
Telegraph
top-k-frequent-elements
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Constraints: