随笔分类 - LeetCode
摘要:题目: 给定一个整数数组,返回所有数对之间的第 k 个最小距离。一对 (A, B) 的距离被定义为 A 和 B 之间的绝对差值。 示例 1: 输入:nums = [1,3,1]k = 1输出:0 解释:所有数对如下:(1,3) -> 2(1,1) -> 0(3,1) -> 2因此第 1 个最小距离的
阅读全文
摘要:题目: 给定一个用字符数组表示的 CPU 需要执行的任务列表。其中包含使用大写的 A - Z 字母表示的26 种不同种类的任务。任务可以以任意顺序执行,并且每个任务都可以在 1 个单位时间内执行完。CPU 在任何一个单位时间内都可以执行一个任务,或者在待命状态。 然而,两个相同种类的任务之间必须有长
阅读全文
摘要:题目: On an infinite number line (x-axis), we drop given squares in the order they are given. The i-th square dropped (positions[i] = (left, side_length
阅读全文
摘要:题目: A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfaces in an efficient manner. ad
阅读全文
摘要:题目: Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: I
阅读全文
摘要:题目: Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency from highest to lowest. If two wor
阅读全文
摘要:题目: There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course 0 you have
阅读全文
摘要:题目: Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer,
阅读全文
摘要:题目: Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to
阅读全文
摘要:题目: Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits
阅读全文
摘要:题目: Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate
阅读全文
摘要:题目: Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations per
阅读全文
摘要:题目: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were in
阅读全文
摘要:题目: Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Ex
阅读全文
摘要:题目: In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of th
阅读全文
摘要:题目: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path b
阅读全文
摘要:题目: Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where
阅读全文
摘要:题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. E
阅读全文
摘要:题目: On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K moves. The rows and columns are 0 indexed, so
阅读全文
摘要:题目: Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the
阅读全文

浙公网安备 33010602011771号