03 2022 档案
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/binary-tree-upside-down 题目描述 给你一个二叉树的根节点 root ,请你将此二叉树上下翻转,并返回新的根节点。 你可以按下面的步骤翻转一棵二叉树: 原来的左子节点变成新的根
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-servers-that-handled-most-number-of-requests 题目描述 你有 k 个服务器,编号为 0 到 k-1 ,它们可以同时处理多个请求组。每个服务器有无
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/first-missing-positive 题目描述 给你一个未排序的整数数组 nums ,请你找出其中没有出现的最小的正整数。 请你实现时间复杂度为 O(n) 并且只使用常数级别额外空间的解决方
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/maximize-the-confusion-of-an-exam 题目描述 一位老师正在出一场由 n 道判断题构成的考试,每道题的答案为 true (用 'T' 表示)或者 false (用 'F
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/valid-sudoku 题目描述 请你判断一个 9 x 9 的数独是否有效。只需要 根据以下规则 ,验证已经填入的数字是否有效即可。 数字 1-9 在每一行只能出现一次。数字 1-9 在每一列只能
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/factorial-trailing-zeroes 题目描述 给定一个整数 n ,返回 n! 结果中尾随零的数量。 提示 n! = n * (n - 1) * (n - 2) * ... * 3 *
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/sudoku-solver 题目描述 编写一个程序,通过填充空格来解决数独问题。 数独的解法需 遵循如下规则: 数字 1-9 在每一行只能出现一次。数字 1-9 在每一列只能出现一次。数字 1-9
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array 题目描述 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/path-with-maximum-gold 题目描述 你要开发一座金矿,地质勘测学家已经探明了这座金矿中的资源分布,并用大小为 m * n 的网格 grid 进行了标注。每个单元格中的整数就表示这
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/k-th-smallest-in-lexicographical-order 题目描述 给定整数 n 和 k,返回 [1, n] 中字典序第 k 小的数字。 示例 1: 输入: n = 13, k
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/longest-valid-parentheses 题目描述 给你一个只包含 '(' 和 ')' 的字符串,找出最长有效(格式正确且连续)括号子串的长度。 示例 1: 输入:s = "(()"输出:
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color 题目描述 总共有 n 个颜色片段排成一列,每个颜色片段要么是 'A' 要么是 '
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/the-time-when-the-network-becomes-idle 题目描述 给你一个有 n 个服务器的计算机网络,服务器编号为 0 到 n - 1 。同时给你一个二维整数数组 edges
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/search-in-rotated-sorted-array 题目描述 整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/simple-bank-system 题目描述 你的任务是为一个很受欢迎的银行设计一款程序,以自动化执行所有传入的交易(转账,存款和取款)。银行共有 n 个账户,编号从 1 到 n 。每个账号的初始
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words 题目描述 给定一个字符串 s 和一些 长度相同 的单词 words 。找出 s 中恰好可以由 words 中所有单
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/next-permutation 题目描述 整数数组的一个 排列 就是将其所有成员以序列或线性顺序排列。 例如,arr = [1,2,3] ,以下这些都可以视作 arr 的排列:[1,2,3]、[1
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/divide-two-integers 题目描述 给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。 返回被除数 dividend
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/all-oone-data-structure 题目描述 请你设计一个用于存储字符串计数的数据结构,并能够返回计数最小和最大的字符串。 实现 AllOne 类: AllOne() 初始化数据结构的对
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/reverse-nodes-in-k-group 题目描述 给你一个链表,每 k 个节点一组进行翻转,请你返回翻转后的链表。 k 是一个正整数,它的值小于或等于链表的长度。 如果节点总数不是 k 的
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/count-number-of-maximum-bitwise-or-subsets 题目描述 给你一个整数数组 nums ,请你找出 nums 子集 按位或 可能得到的 最大值 ,并返回按位或能得
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/merge-k-sorted-lists 题目描述 给你一个链表数组,每个链表都已经按升序排列。 请你将所有链表合并到一个升序链表中,返回合并后的链表。 示例 1: 输入:lists = [[1,4
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/generate-parentheses 题目描述 数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。 示例 1: 输入:n = 3输出:["((()))
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/utf-8-validation 题目描述 给定一个表示数据的整数数组 data ,返回它是否为有效的 UTF-8 编码。 UTF-8 中的一个字符可能的长度为 1 到 4 字节,遵循以下的规则:
阅读全文
摘要:来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/count-nodes-with-the-highest-score 题目描述 给你一棵根节点为 0 的 二叉树 ,它总共有 n 个节点,节点编号为 0 到 n - 1 。同时给你一个下标从 0
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/online-election 题目描述 给你两个整数数组 persons 和 times 。在选举中,第 i 张票是在时刻为 times[i] 时投给候选人 persons[i] 的。 对于发生在
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/smallest-rotation-with-highest-score 题目描述 给你一个数组 nums,我们可以将它按一个非负整数 k 进行轮调,这样可以使数组变为 [nums[k], nums
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/plates-between-candles 题目描述 给你一个长桌子,桌子上盘子和蜡烛排成一列。给你一个下标从 0 开始的字符串 s ,它只包含字符 '*' 和 '|' ,其中 '*' 表示一个
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/optimal-division 题目描述 给定一组正整数,相邻的整数之间将会进行浮点除法操作。例如, [2,3,4] -> 2 / 3 / 4 。 但是,你可以在任意位置添加任意数目的括号,来改变
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-good-days-to-rob-the-bank 题目描述 你和一群强盗准备打劫银行。给你一个下标从 0 开始的整数数组 security ,其中 security[i] 是第 i 天执
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/sum-of-subarray-ranges 题目描述 给你一个整数数组 nums 。nums 中,子数组的 范围 是子数组中最大元素和最小元素的差值。 返回 nums 中 所有 子数组范围的 和
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/repeated-string-match 题目描述 给定两个字符串 a 和 b,寻找重复叠加字符串 a 的最小次数,使得字符串 b 成为叠加后的字符串 a 的子串,如果不存在则返回 -1。 注意:
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-the-closest-palindrome 题目描述 给定一个表示整数的字符串 n ,返回与它最近的回文整数(不包括自身)。如果不止一个,返回较小的那个。 “最近的”定义为两个整数差的绝
阅读全文
摘要:来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/zigzag-conversion 题目描述 将一个给定字符串 s 根据给定的行数 numRows ,以从上往下、从左到右进行 Z 字形排列。 比如输入字符串为 "PAYPALISHIRING" 行
阅读全文