- 博客(70)
- 资源 (1)
- 收藏
- 关注
转载 166. Fraction to Recurring Decimal
题目: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 parent
2016-05-31 15:30:11 239
转载 49. Group Anagrams
题目:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]
2016-05-31 13:47:52 285
转载 347. Top K Frequent Elements
题目:Given 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 always valid, 1 ≤ k
2016-05-31 10:52:43 271
转载 136. Single Number
题目:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without
2016-05-31 10:19:54 202
转载 94. Binary Tree Inorder Traversal
题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursiv
2016-05-30 16:04:47 246
转载 290. Word Pattern
题目:Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word
2016-05-30 14:52:49 301
转载 242. Valid Anagram
题目:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:Yo
2016-05-30 14:30:02 260
转载 349. 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 uniqu
2016-05-30 11:51:01 193
转载 299. Bulls and Cows
题目:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide
2016-05-27 11:12:26 263
转载 202. Happy Number
题目:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of th
2016-05-27 10:19:27 250
转载 204. Count Primes
题目:Description:Count the number of prime numbers less than a non-negative number, n.题意:统计小于非负整数n的素数的个数,素数不能被比它小的整数整除。思路:解题思路入提示二所示,埃拉托斯特尼筛法Sieve of Eratosthenes中,算法过程如下图所示,我们从2开始
2016-05-27 08:56:25 222
转载 36. Valid Sudoku
题目:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partia
2016-05-26 14:57:46 201
转载 350. Intersection of Two Arrays II
题目:Given 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 the result should app
2016-05-26 13:33:04 278
转载 205. Isomorphic Strings
题目:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced
2016-05-26 11:38:51 249
转载 85. Maximal Rectangle
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题意:给定一个充满0和1的二维矩阵,找到包含最多1的矩形并返回其面积。思路:
2016-05-25 14:06:02 215
转载 287. Find the Duplicate Number
题目:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate n
2016-05-25 10:54:46 227
转载 216. Combination Sum III
题目:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Ensure that n
2016-05-25 10:21:34 216
转载 209. Minimum Size Subarray Sum
题目:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the a
2016-05-24 16:10:04 181
转载 228. Summary Ranges
题目:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].题意:给定一个已经排好序且没有重复数子的整数数组,返回它的范围总结,即将相邻的一
2016-05-24 14:53:50 168
转载 229. Majority Element II
题目:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.Hint:How many majority elements co
2016-05-24 11:51:32 223
转载 162. Find Peak Element
题目:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple p
2016-05-24 10:59:24 157
转载 40. Combination Sum II
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in Cwhere the candidate numbers sums to T.Each number in C may only be used once in the
2016-05-24 09:35:31 165
转载 153. Find Minimum in Rotated Sorted Array
题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate e
2016-05-24 09:01:23 167
转载 152. Maximum Product Subarray
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the
2016-05-23 10:35:53 206
转载 39. Combination Sum
题目:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlim
2016-05-20 14:17:41 179
转载 35. Search Insert Position
题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in t
2016-05-20 13:40:07 166
转载 34. Search for a Range
题目:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is n
2016-05-20 11:38:31 183
转载 122. Best Time to Buy and Sell Stock II
题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i
2016-05-20 10:46:58 166
转载 238. Product of Array Except Self
题目:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division
2016-05-20 09:18:43 181
转载 120. Triangle
题目:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3
2016-05-19 16:08:08 180
转载 106. Construct Binary Tree from Inorder and Postorder Traversal
题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题意:给定中序遍历跟后序遍历构建完整二叉树note:可以假设该二叉
2016-05-19 10:54:56 199
转载 105. Construct Binary Tree from Preorder and Inorder Traversal
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题意:根据给定的前序遍历与中序遍历构造二叉树note:可以假设在二叉
2016-05-19 09:13:50 218
转载 90. Subsets II
题目:Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not c
2016-05-18 14:28:02 183
转载 268. Missing Number
题目:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algori
2016-05-18 13:01:18 176
转载 11. Container With Most Water
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
2016-05-18 09:34:15 176
转载 31. Next Permutation
题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest
2016-05-17 14:03:38 275
转载 81. Search in Rotated Sorted Array II
题目:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target
2016-05-17 09:44:02 182
转载 33. Search in Rotated Sorted Array
题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in th
2016-05-17 08:57:14 168
转载 80. Remove Duplicates from Sorted Array II
题目:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the
2016-05-16 16:23:22 194
转载 79. Word Search
题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or v
2016-05-16 09:17:58 238
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人