leetcode
文章平均质量分 70
沙虫zZ
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Top K Frequent Elements
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原创 2016-05-24 22:19:59 · 281 阅读 · 0 评论 -
Surrounded Regions
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X原创 2016-08-23 16:00:47 · 236 阅读 · 0 评论 -
Search for a Range
search for a rangeGiven 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原创 2016-08-18 11:32:57 · 262 阅读 · 0 评论 -
sort colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0,原创 2016-08-17 10:35:18 · 519 阅读 · 0 评论 -
x&(x-1)
刷leetcode的时候,发现了很多使用到x&(x-1)的题目。顺便在网上查了查,做了总结:求下面函数的返回值(微软) -- 统计1的个数-------------------------------------int func(int x){ int countx = 0; while(x) { countx++;原创 2016-07-16 11:42:32 · 312 阅读 · 0 评论 -
Group Anagrams
Group AnagramsGiven an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","原创 2016-05-21 17:02:43 · 558 阅读 · 0 评论 -
Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not原创 2016-05-21 16:34:40 · 227 阅读 · 0 评论 -
Kth Smallest Element in a BST
Kth Smallest Element in a BSTGiven a binary search tree, write a function kthSmallest to find thekth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤原创 2016-05-20 16:00:58 · 250 阅读 · 0 评论 -
Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].原创 2016-05-19 19:05:45 · 204 阅读 · 0 评论 -
Permutations
Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1],[3,1,2], and [3,2,1].看完一遍题原创 2016-05-18 19:57:27 · 212 阅读 · 0 评论 -
Single Number II
Single Number IIGiven an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity原创 2016-05-17 22:01:06 · 382 阅读 · 0 评论 -
Power of two,power of three,power of four
Power of TwoTotal Accepted: 3596 Total Submissions: 11779Given an integer, write a function to determine if it is a power of two.Credits:Special thanks to @jianchao.li.fighter for addi原创 2016-05-17 20:23:13 · 276 阅读 · 0 评论 -
Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 y原创 2016-05-16 22:08:07 · 245 阅读 · 0 评论 -
Lowest Common Ancestor of a Binary Tree
Lowest Common Ancestor of a Binary TreeGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest原创 2016-05-28 13:40:47 · 227 阅读 · 0 评论 -
Gas Station
There are N gas stations along a circular route, where the amount of gas at stationi is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from stationi to it原创 2016-05-26 10:44:14 · 461 阅读 · 0 评论 -
Number of Digit One
Number of Digit OneGiven an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 o原创 2016-09-05 21:12:09 · 314 阅读 · 0 评论
分享