
LeetCode
文章平均质量分 66
qq_34229391
xuezhayimei,xiquqianbeijingyan
展开
-
330. Patching Array
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Retu...原创 2018-09-01 13:44:35 · 174 阅读 · 0 评论 -
345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Input: "hello"Output: "holle"Example 2:Input: "leetcode"Output: "leotcede"Note: T...原创 2018-09-16 14:03:20 · 118 阅读 · 0 评论 -
349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2]Example 2:Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]Output...原创 2018-09-16 14:04:53 · 114 阅读 · 0 评论 -
350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2,2]Example 2:Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]Outp...原创 2018-09-16 14:06:20 · 107 阅读 · 0 评论 -
347. Top K Frequent Elements
Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]Note:...原创 2018-09-16 14:08:02 · 134 阅读 · 0 评论 -
343. Integer Break
Given a positive integer nnn, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.Example 1:Input: 2Outp...原创 2018-09-16 14:09:30 · 108 阅读 · 0 评论 -
341. Flatten Nested List Iterator
Given 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 or other lists.Example 1:Input: [[...原创 2018-09-16 14:31:29 · 170 阅读 · 0 评论 -
354. Russian Doll Envelopes
You 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 height of one envelope is greater tha...原创 2018-09-16 15:17:30 · 346 阅读 · 0 评论 -
367. Valid Perfect Square
Given 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 sqrt.Example 1:Input: 16...原创 2018-09-16 15:31:07 · 210 阅读 · 0 评论 -
335. Self Crossing
You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3] metres to the east and so on. ...原创 2018-09-10 11:36:48 · 335 阅读 · 0 评论 -
328. Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in p...原创 2018-09-06 14:14:32 · 264 阅读 · 0 评论 -
334. Increasing Triplet Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should: Return true if there exists i, j, k such that arr[i] &...原创 2018-09-10 00:58:03 · 169 阅读 · 0 评论 -
327. Count of Range Sum
Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), inc...原创 2018-09-06 13:32:58 · 183 阅读 · 0 评论 -
321. Create Maximum Number
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same ar...原创 2018-09-01 15:06:45 · 171 阅读 · 0 评论 -
322. Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money ...原创 2018-09-01 20:18:38 · 107 阅读 · 0 评论 -
376. Wiggle Subsequence
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either pos...原创 2018-09-01 23:16:23 · 130 阅读 · 0 评论 -
324. Wiggle Sort II
Given an unsorted array nums, reorder it such thatnums[0] < nums[1] > nums[2] < nums[3]....Example 1:Input: nums = [1, 5, 1, 1, 6, 4]Output: One possible answer is [1, 4, 1, 5, 1原创 2018-09-04 23:50:53 · 118 阅读 · 0 评论 -
326. Power of Three,342. Power of Four
Power of ThreeGiven an integer, write a function to determine if it is a power of three.Example 1:Input: 27Output: trueExample 2:Input: 0Output: falseExample 3:_Input: 9Output: ...原创 2018-09-05 14:45:10 · 178 阅读 · 0 评论 -
329. Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside o...原创 2018-09-09 10:22:53 · 127 阅读 · 0 评论 -
331. Verify Preorder Serialization of a Binary Tree
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node\’s value. If it is a null node, we record using a sentinel value such as #. ...原创 2018-09-09 10:25:01 · 127 阅读 · 0 评论 -
332. Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, ...原创 2018-09-09 10:28:02 · 159 阅读 · 0 评论 -
344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example 1:Input: "hello"Output: "olleh"Example 2:Input: "A man, a plan, a canal: Panama"Output: "amanaP :lan...原创 2018-09-09 10:29:24 · 169 阅读 · 0 评论 -
337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour...原创 2018-09-10 15:55:28 · 195 阅读 · 0 评论