Math
weixin_39145266
这个作者很懒,什么都没留下…
展开
-
1218 Longest Arithmetic Subsequence of Given Difference
1 题目Given an integer arrayarrand an integerdifference, return the length of the longest subsequence inarrwhich is an arithmetic sequence such that the difference between adjacent elements in th...原创 2019-12-24 06:21:58 · 106 阅读 · 0 评论 -
1104 Path In Zigzag Labelled Binary Tree
1 题目In an infinite binary tree where every node has two children, the nodes are labelled in row order.In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, w...原创 2019-11-26 14:33:59 · 88 阅读 · 0 评论 -
319 Bulb Switcher
1 题目There arenbulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turnin...原创 2019-06-26 17:26:58 · 59 阅读 · 0 评论 -
357 Count Numbers with Unique Digits
1 题目Given anon-negativeinteger n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example:Input: 2Output: 91 Explanation: The answer should be the total numbers in the range o...原创 2019-07-07 21:07:04 · 58 阅读 · 0 评论 -
462 Minimum Moves to Equal Array Elements II
1 题目Given anon-emptyinteger array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected eleme...原创 2019-07-13 10:47:02 · 59 阅读 · 0 评论 -
368 Largest Divisible Subset
1 题目Given a set ofdistinctpositive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies:Si% Sj= 0 or Sj% Si= 0.If there are multiple solutio...原创 2019-07-10 15:05:12 · 94 阅读 · 0 评论 -
397 Integer Replacement
1 题目Given a positive integernand you can do operations as follow:Ifnis even, replacenwithn/2. Ifnis odd, you can replacenwith eithern+ 1orn- 1.What is the minimum number of repla...原创 2019-07-10 22:42:57 · 43 阅读 · 0 评论 -
343 Integer Break
1 题目Given a positive integern, break it into the sum ofat leasttwo positive integers and maximize the product of those integers. Return the maximum product you can get.Example 1:Input: 2Out...原创 2019-07-07 15:15:09 · 56 阅读 · 0 评论 -
413 Arithmetic Slices
1 题目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 same.For example, these are arithmetic seq...原创 2019-07-12 15:29:58 · 119 阅读 · 0 评论 -
1025 Divisor Game
1 题目Alice and Bob take turns playing a game, with Alice starting first.Initially, there is a numberNon the chalkboard. On each player's turn, that player makes amoveconsisting of:Choosinga...原创 2019-08-03 12:00:38 · 122 阅读 · 0 评论 -
313 Super Ugly Number
1 题目Write a program to find thenthsuper ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime listprimesof sizek.Example:Input: n = 12, prime...原创 2019-05-07 17:51:53 · 64 阅读 · 0 评论 -
400 Nth Digit
1题目Find thenthdigit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:nis positive and will fit within the range of a 32-bit signed integer (n< 231).Example 1:...原创 2019-05-08 15:14:00 · 82 阅读 · 0 评论 -
223 Rectangle Area
1 题目Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Example:Input: A...原创 2019-04-23 17:10:57 · 84 阅读 · 0 评论 -
12 Integer to Roman
1 题目Roman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2019-03-29 09:16:25 · 43 阅读 · 0 评论 -
29 Divide Two Integers
1 题目Given two integersdividendanddivisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividingdividendbydivisor.The integer divisi...原创 2019-03-29 09:18:55 · 113 阅读 · 0 评论 -
279 Perfect Squares
1 题目Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4.E...原创 2019-04-08 15:47:35 · 87 阅读 · 0 评论 -
264 Ugly Number II
1 题目Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example:Input: n = 10Output: 12Explanation: 1, 2, 3, 4, 5, 6, 8,...原创 2019-04-11 21:47:42 · 68 阅读 · 0 评论 -
166 Fraction to Recurring Decimal
1 题目Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses...原创 2019-04-03 10:22:03 · 168 阅读 · 0 评论 -
43 Multiply Strings
1 题目Given two non-negative integersnum1andnum2represented as strings, return the product ofnum1andnum2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"...原创 2019-04-03 10:40:42 · 64 阅读 · 0 评论 -
60 Permutation Sequence
1 题目The set[1,2,3,...,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order, we get the following sequence forn= 3:"123" "132" "213" "231"...原创 2019-04-03 11:27:17 · 70 阅读 · 0 评论 -
50 Pow(x, n)
Implementpow(x,n), which calculatesxraised to the powern(xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, ...原创 2019-04-03 12:42:13 · 71 阅读 · 0 评论 -
204 Count Primes
1 题目Count the number of prime numbers less than a non-negative number,n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.2 尝试解2.1 分析从2...原创 2019-04-26 17:46:15 · 82 阅读 · 0 评论 -
8 String to Integer (atoi)
1 题目Implementatoiwhichconverts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting fr...原创 2019-03-29 09:16:08 · 58 阅读 · 0 评论