随笔分类 - Leetcode
发表于 2021-04-16 21:30阅读:160评论:0推荐:0
摘要:给你一个字符串 s ,每一次操作你都可以在字符串的任意位置插入任意字符。 请你返回让 s 成为回文串的 最少操作次数 。 「回文串」是正读和反读都相同的字符串。 示例 1: 输入:s = "zzazz"输出:0解释:字符串 "zzazz" 已经是回文串了,所以不需要做任何插入操作。示例 2: 输入:
阅读全文 »
发表于 2020-05-10 18:05阅读:323评论:0推荐:0
摘要:Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one
阅读全文 »
发表于 2020-05-03 18:22阅读:547评论:0推荐:0
摘要:Given an array of integers nums and an integer limit, return the size of the longest continuous subarray such that the absolute difference between any
阅读全文 »
发表于 2020-05-03 17:28阅读:233评论:0推荐:0
摘要:You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order. You are allowed to choose exactly 1 element f
阅读全文 »
发表于 2020-04-12 17:45阅读:243评论:0推荐:0
摘要:1408. String Matching in an Array Given an array of string words. Return all strings in words which is substring of another word in any order. String
阅读全文 »
发表于 2019-06-02 16:33阅读:325评论:0推荐:0
摘要:1071. Greatest Common Divisor of Strings For strings S and T, we say "T divides S" if and only if S = T + ... + T (T concatenated with itself 1 or mor
阅读全文 »
发表于 2019-05-31 22:30阅读:172评论:0推荐:0
摘要:Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing su
阅读全文 »
发表于 2019-05-31 21:18阅读:24189评论:0推荐:0
摘要:Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls i
阅读全文 »
发表于 2019-05-30 22:32阅读:252评论:0推荐:0
摘要:Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one s
阅读全文 »
发表于 2019-05-30 22:00阅读:223评论:0推荐:0
摘要:Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and
阅读全文 »
发表于 2019-05-29 16:31阅读:335评论:0推荐:0
摘要:Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two). The returned string must have no le
阅读全文 »
发表于 2019-05-29 15:53阅读:380评论:0推荐:0
摘要:On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L
阅读全文 »
发表于 2019-05-28 22:04阅读:285评论:0推荐:0
摘要:Given an array A of non-negative integers, the array is squareful if for every pair of adjacent elements, their sum is a perfect square. Return the nu
阅读全文 »
发表于 2019-05-28 20:58阅读:317评论:0推荐:0
摘要: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
阅读全文 »
发表于 2019-05-27 22:35阅读:210评论:0推荐:0
摘要: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
阅读全文 »
发表于 2019-05-26 12:43阅读:230评论:0推荐:0
摘要:1051. Height Checker Students are asked to stand in non-decreasing order of heights for an annual photo. Return the minimum number of students not sta
阅读全文 »
发表于 2019-05-24 22:13阅读:277评论:0推荐:0
摘要:Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these points, with sides not necessarily parallel to th
阅读全文 »
发表于 2019-05-23 21:43阅读:203评论:0推荐:0
摘要:Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and add x to A[i]. After this process, we have some array B
阅读全文 »
发表于 2019-05-23 21:28阅读:347评论:0推荐:0
摘要:Let's say a positive integer is a superpalindrome if it is a palindrome, and it is also the square of a palindrome. Now, given two positive integers L
阅读全文 »
发表于 2019-05-23 20:30阅读:266评论:0推荐:0
摘要:On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Return the
阅读全文 »