随笔分类 - LeetCode
摘要:Implement a data structure supporting the following operations: Challenge: Perform all these in O(1) time complexity. 这道题让我们实现一个全是O(1)复杂度的数据结构,包括了增加ke
阅读全文
摘要:Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum. The
阅读全文
摘要:Given a set of words (without duplicates), find all word squares you can build from them. A sequence of words forms a valid word square if the kth row
阅读全文
摘要:Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the
阅读全文
摘要:Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. Note: Example 1: Examp
阅读全文
摘要:Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a valid word square if the kth row and column read th
阅读全文
摘要:Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum result of ai XOR aj, where 0 ≤ i, j < n. Could you do t
阅读全文
摘要:A password is considered strong if below conditions are all met: Write a function strongPasswordChecker(s), that takes a string s as input, and return
阅读全文
摘要:Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. E
阅读全文
摘要:Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may ass
阅读全文
摘要:Given a rows x cols screen and a sentence represented by a list of words, find how many times the given sentence can be fitted on the screen. Note: Ex
阅读全文
摘要:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the
阅读全文
摘要:Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the numbe
阅读全文
摘要:Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top
阅读全文
摘要:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both
阅读全文
摘要:Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100.
阅读全文
摘要:A string such as "word" contains the following abbreviations: ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1
阅读全文
摘要:Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algor
阅读全文
摘要:Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. L
阅读全文
摘要:Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains o
阅读全文