随笔分类 - LeetCode
摘要:A B D均比较简单。先说C题 K-Concatenation Maximum Sum Given an integer array arr and an integer k, modify the array by repeating it k times. For example, if arr
阅读全文
摘要:给定字符串 S,找出最长重复子串的长度。如果不存在重复子串就返回 0。 示例 1: 示例 2: 示例 3: 示例 4: 提示: https://www.nowcoder.com/questionTerminal/859d3e13ebb24e73861e03141bbe9cfb?from=14pdf
阅读全文
摘要:给出长度相同的两个字符串:A 和 B,其中 A[i] 和 B[i] 是一组等价字符。举个例子,如果 A = "abc" 且 B = "cde",那么就有 'a' == 'c', 'b' == 'd', 'c' == 'e'。 等价字符遵循任何等价关系的一般规则: 自反性:'a' == 'a' 对称性
阅读全文
摘要:给出一个有序数组 A,数组中的每个数字都是 独一无二的,找出从数组最左边开始的第 K 个缺失数字。 示例 1: 示例 2: 示例 3: 提示: 没啥好说的。注意超过数组最大值的就不要去遍历了。直接算! 这题的正解应该也是直接算的。。
阅读全文
摘要:给定一个数字 N,当它满足以下条件的时候返回 true: 把原数字旋转180°以后得到新的数字。 如 0, 1, 6, 8, 9 旋转 180° 以后,得到了新的数字 0, 1, 9, 8, 6 。 2, 3, 4, 5, 7 旋转 180° 后,得到的不是数字。 易混淆数字 (confusing
阅读全文
摘要:A conveyor belt has packages that must be shipped from one port to another within D days. The i-th package on the conveyor belt has a weight of weight
阅读全文
摘要:In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is
阅读全文
摘要:Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on. Not
阅读全文
摘要:On a broken calculator that has a number showing on its display, we can perform two operations: Double: Multiply the number on the display by 2, or; D
阅读全文
摘要:For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [
阅读全文
摘要:Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. Example 1: Input: A = [4,5,0,-2,-
阅读全文
摘要:Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths. If it is impossib
阅读全文
摘要:We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclid
阅读全文
摘要:Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, then reverse the order of the first kelements of A. We
阅读全文
摘要:Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. Return a list of all
阅读全文
摘要:Given a binary tree, determine if it is a complete binary tree. Definition of a complete binary tree from Wikipedia:In a complete binary tree every le
阅读全文
摘要:There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to t
阅读全文
摘要:Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j]. The width of such a ramp is j - i. Find the maximum width of
阅读全文
摘要:In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. Return the element repeated N times. Ex
阅读全文
摘要:Given an array of integers A with even length, return true if and only if it is possible to reorder it such that A[2 * i + 1] = 2 * A[2 * i]for every
阅读全文