随笔分类 - LeetCode
摘要:You want to form a string of lowercase letters. At the beginning, your sequence is `'?' stamp` of lowercase letters. On each turn, you may place the s
阅读全文
摘要:The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square ver
阅读全文
摘要:Write a class to count recent requests. It has only one method: , where t represents some time in milliseconds. Return the number of s that have been
阅读全文
摘要:In a given 2D binary array , there are two islands. (An island is a 4 directionally connected group of s not connected to any other 1s.) Now, we may c
阅读全文
摘要:For some fixed , an array is beautiful if it is a permutation of the integers , such that: For every `i 这道题定义了一种漂亮数组,说的是在任意两个数字之间,不存在一个正好是这两个数之和的一半的数字
阅读全文
摘要:Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first
阅读全文
摘要:In an array A of 0s and 1s, how many non-empty subarrays have sum S? Example 1: Input: A = [1,0,1,0,1], S = 2 Output: 4 Explanation: The 4 subarrays a
阅读全文
摘要:Every email consists of a local name and a domain name, separated by the @ sign. For example, in , is the local name, and is the domain name. Besides
阅读全文
摘要:(This problem is the same as Minimize Malware Spread, with the differences bolded.) In a network of nodes, each node i is directly connected to anothe
阅读全文
摘要:Given an array of s and s, divide the array into 3 non empty parts such that all of these parts represent the same binary value. If it is possible, re
阅读全文
摘要:A string of s and s is monotone increasing if it consists of some number of s (possibly 0), followed by some number of s (also possibly 0.) We are giv
阅读全文
摘要:Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed
阅读全文
摘要:In a network of nodes, each node is directly connected to another node if and only if . Some nodes are initially infected by malware. Whenever two nod
阅读全文
摘要:Given an integer array , and an integer , return the number of tuples such that `i 这道题是之前那道 "3Sum" 的拓展,之前那道题是说没有重复数字,而这道题却有大量的重复数字,所以每个组合可能会大量重复出现,让我们
阅读全文
摘要:Given an array of non negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that whenever is odd,
阅读全文
摘要:Given a string of and parentheses, we add the minimum number of parentheses ( or , and in any positions ) so that the resulting parentheses string is
阅读全文
摘要:Your music player contains different songs and she wants to listen to (not necessarily different) songs during your trip. You create a playlist so tha
阅读全文
摘要:A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possibl
阅读全文
摘要:Given a circular array C of integers represented by , find the maximum possible sum of a non empty subarray of C. Here, a circular array means the end
阅读全文
摘要:Given a string , return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positio
阅读全文