随笔分类 -  LeetCode

摘要:题目: 给定一个整数数组,返回所有数对之间的第 k 个最小距离。一对 (A, B) 的距离被定义为 A 和 B 之间的绝对差值。 示例 1: 输入:nums = [1,3,1]k = 1输出:0 解释:所有数对如下:(1,3) -> 2(1,1) -> 0(3,1) -> 2因此第 1 个最小距离的 阅读全文
posted @ 2020-11-28 19:01 silentteller 阅读(204) 评论(0) 推荐(0)
摘要:题目: 给定一个用字符数组表示的 CPU 需要执行的任务列表。其中包含使用大写的 A - Z 字母表示的26 种不同种类的任务。任务可以以任意顺序执行,并且每个任务都可以在 1 个单位时间内执行完。CPU 在任何一个单位时间内都可以执行一个任务,或者在待命状态。 然而,两个相同种类的任务之间必须有长 阅读全文
posted @ 2020-11-20 15:47 silentteller 阅读(214) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-05-11 15:01 silentteller 阅读(308) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-05-07 14:04 silentteller 阅读(328) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-04-29 19:32 silentteller 阅读(278) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-04-29 18:55 silentteller 阅读(283) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-29 15:27 silentteller 阅读(299) 评论(0) 推荐(0)
摘要:题目: 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, 阅读全文
posted @ 2020-02-29 14:44 silentteller 阅读(295) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-28 12:35 silentteller 阅读(283) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-27 15:53 silentteller 阅读(258) 评论(0) 推荐(0)
摘要:题目: Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate 阅读全文
posted @ 2020-02-27 14:59 silentteller 阅读(210) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-26 15:05 silentteller 阅读(409) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-26 13:49 silentteller 阅读(244) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-26 12:58 silentteller 阅读(617) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-25 14:52 silentteller 阅读(269) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-24 17:17 silentteller 阅读(385) 评论(0) 推荐(0)
摘要:题目: Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where 阅读全文
posted @ 2020-02-24 16:46 silentteller 阅读(347) 评论(0) 推荐(0)
摘要:题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. E 阅读全文
posted @ 2020-02-24 16:01 silentteller 阅读(268) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-23 19:57 silentteller 阅读(261) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2020-02-23 18:59 silentteller 阅读(330) 评论(0) 推荐(0)