[LeetCode]Flatten Nested List Iterator
题目描述:LeetCode 341. Flatten Nested List IteratorGiven a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers...
View Article[LeetCode]Power of Four
题目描述:LeetCode 342. Power of FourGiven an integer (signed 32 bits), write a function to check whether it is a power of 4.Example: Given num = 16, return true. Given num = 5, return false.Follow up:...
View Article[LeetCode]Integer Break
题目描述:LeetCode 343. Integer BreakGiven a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can...
View Article[LeetCode]Reverse String
题目描述:LeetCode 344. Reverse StringWrite a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".题目大意:编写函数输入字符串,返回其逆置。例如输入s =...
View Article[LeetCode]Reverse Vowels of a String
题目描述:LeetCode 345. Reverse Vowels of a StringWrite a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s =...
View Article[LeetCode]Top K Frequent Elements
题目描述:LeetCode 347. Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is...
View Article[LeetCode]Intersection of Two Arrays
题目描述:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The result can be in...
View Article[LeetCode]Intersection of Two Arrays II
题目描述:LeetCode 350. Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in...
View Article[LeetCode]Data Stream as Disjoint Intervals
题目描述:LeetCode 352. Data Stream as Disjoint Intervals Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.For...
View Article[LeetCode]Russian Doll Envelopes
题目描述:LeetCode 354. Russian Doll EnvelopesYou have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and...
View Article[LeetCode]Design Twitter
题目描述:LeetCode 355. Design Twitter design-twitterDesign a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the...
View Article[LeetCode]Count Numbers with Unique Digits
题目描述:LeetCode 357. Count Numbers with Unique DigitsGiven a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example:Given n = 2, return 91. (The answer should be...
View Article[LeetCode]Max Sum of Rectangle No Larger Than K
题目描述:LeetCode 363. Max Sum of Rectangle No Larger Than KGiven a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.Example:...
View Article[LeetCode]Water and Jug Problem
题目描述:LeetCode 365. Water and Jug ProblemYou are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to...
View Article[LeetCode]Valid Perfect Square
题目描述:LeetCode 367. Valid Perfect SquareGiven a positive integer num, write a function which returns True if num is a perfect square else False.Note:Do not use any built-in library function such as...
View Article[LeetCode]Largest Divisible Subset
题目描述:LeetCode 368. Largest Divisible SubsetGiven a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si...
View Article[LeetCode]Sum of Two Integers
题目描述:LeetCode 371. Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return...
View Article[LeetCode]Find K Pairs with Smallest Sums
题目描述:LeetCode 373. Find K Pairs with Smallest SumsYou are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u,v) which consists of one element from the...
View Article[LeetCode]Super Pow
题目描述:LeetCode 372. Super PowYour task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example1: a = 2 b = [3]...
View Article[LeetCode]Guess Number Higher or Lower
题目描述:LeetCode 374. Guess Number Higher or LowerWe are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong,...
View Article