- 博客(284)
- 收藏
- 关注
原创 求一个整数stream的sum, avg, median
好久没更新了, 上个新题吧。 求一个整数stream的sum, avg, median。 数据不断流入, 随时求sum, avg, median 1) consume(int value) 2 million 2) getSum() 3) getAverage() 4) getMedian() 1 2 -1 0 getSum => 1+2-1+0 4
2016-10-07 17:22:00
4522
原创 leetcode 303: Range Sum Query - Immutable
Range Sum Query - ImmutableTotal Accepted: 696 Total Submissions: 2406 Difficulty: EasyGiven an integer array nums, find the sum of the elements between indicesi and j (i ≤ j), i
2015-11-10 17:47:28
5569
原创 leetcode 301: Smallest Rectangle Enclosing Black Pixels
Smallest Rectangle Enclosing Black PixelsTotal Accepted: 575 Total Submissions: 1481 Difficulty: MediumAn image is represented by a binary matrix with 0 as a white pixel and1 as a
2015-11-09 14:37:58
3656
原创 leetcode 300: Longest Increasing Subsequence
Longest Increasing SubsequenceTotal Accepted: 53 Total Submissions: 172 Difficulty: MediumGiven an unsorted array of integers, find the length of longest increasing subsequence.For
2015-11-03 11:24:29
4374
原创 leetcode 298: Binary Tree Longest Consecutive Sequence
Binary Tree Longest Consecutive SequenceTotal Accepted: 437 Total Submissions: 1351 Difficulty: MediumGiven a binary tree, find the length of the longest consecutive sequence path.
2015-10-29 16:35:32
6668
原创 leetcode 296: Best Meeting Point
Best Meeting PointTotal Accepted: 701 Total Submissions: 1714 Difficulty: MediumA group of two or more people wants to meet and minimize the total travel distance. You are given a 2D
2015-10-26 09:59:50
7203
原创 leetcode 290: Word Pattern
Word PatternTotal Accepted: 1733 Total Submissions: 6204 Difficulty: EasyGiven a pattern and a string str, find if str follows the same pattern.Examples:pattern = "abba", s
2015-10-06 16:10:22
6749
原创 leetcode 289: Game of Life
Game of LifeTotal Accepted: 606 Total Submissions: 1907 Difficulty: MediumAccording to the Wikipedia's article: "The Game of Life, also known simply asLife, is a cellular automat
2015-10-04 15:19:14
9473
原创 leetcode 288: Unique Word Abbreviation
Unique Word AbbreviationTotal Accepted: 351 Total Submissions: 2106 Difficulty: EasyAn abbreviation of a word follows the form . Below are some examples of word abbreviations:a) it
2015-10-02 16:20:23
6689
原创 leetcode 287: Find the Duplicate Number
Find the Duplicate NumberTotal Accepted: 1340 Total Submissions: 4766 Difficulty: HardGiven an array nums containing n + 1 integers where each integer is between 1 andn (incl
2015-09-29 08:29:12
8716
原创 leetcode 243: Shortest Word Distance
Shortest Word DistanceTotal Accepted: 1754 Total Submissions: 4239 Difficulty: EasyGiven a list of words and two words word1 and word2, return the shortest distance between these two
2015-09-27 15:15:26
5289
原创 leetcode 272: Closest Binary Search Tree Value II
Closest Binary Search Tree Value IITotal Accepted: 984 Total Submissions: 3704 Difficulty: HardGiven a non-empty binary search tree and a target value, find k values in the BST tha
2015-09-26 18:09:09
6459
原创 leetcode 270: Closest Binary Search Tree Value
Closest Binary Search Tree ValueTotal Accepted: 1815 Total Submissions: 6418 Difficulty: EasyGiven a non-empty binary search tree and a target value, find the value in the BST that
2015-09-26 09:43:21
7546
原创 leetcode 277: Find the Celebrity
Find the CelebrityTotal Accepted: 1126 Total Submissions: 3603 Difficulty: MediumSuppose you are at a party with n people (labeled from 0 ton - 1) and among them, there may exist
2015-09-26 09:04:47
6540
原创 leetcode 281: Zigzag Iterator
Zigzag IteratorTotal Accepted: 964 Total Submissions: 2714 Difficulty: MediumGiven two 1d vectors, implement an iterator to return their elements alternately.For example, given t
2015-09-26 08:32:15
6272
原创 leetcode 280: Wiggle Sort
Wiggle SortTotal Accepted: 1291 Total Submissions: 3008 Difficulty: MediumGiven an unsorted array nums, reorder it in-place such thatnums[0] = nums[2] .For example, given nums
2015-09-26 07:44:26
8030
原创 leetcode 286: Walls and Gates
Walls and GatesTotal Accepted: 411 Total Submissions: 1365 Difficulty: MediumYou are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an obstac
2015-09-26 06:09:33
6959
原创 leetcode 284: Peeking Iterator
Peeking IteratorTotal Accepted: 2156 Total Submissions: 6859 Difficulty: MediumGiven an Iterator class interface with methods: next() and hasNext(), design and implement a Peekin
2015-09-24 02:18:04
5004
原创 leetcode 283: Move Zeroes
Move ZeroesTotal Accepted: 858 Total Submissions: 1878 Difficulty: EasyGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order o
2015-09-19 13:32:31
8534
原创 leetcode 279: Perfect Squares
Perfect SquaresTotal Accepted: 605 Total Submissions: 1956 Given a positive integer n, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which su
2015-09-10 06:03:01
9262
原创 leetcode 268: Missing Number
Missing NumberTotal Accepted: 10033 Total Submissions: 31720Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For e
2015-09-08 09:19:12
2887
原创 leetcode 278: First Bad Version
First Bad VersionTotal Accepted: 1415 Total Submissions: 5826You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your
2015-09-08 08:49:49
5163
原创 leetcode 275: H-Index II
Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm?[思路]二分查找, [CODE]public class Solution { public int hIndex(int[]
2015-09-05 17:09:29
3220
原创 leetcode 274: H-Index
H-IndexTotal Accepted: 2684 Total Submissions: 11955Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researche
2015-09-05 16:30:51
4196
原创 leetcode 264: Ugly Number II
Ugly Number IITotal Accepted: 2920 Total Submissions: 15174Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For
2015-08-23 10:53:33
6087
原创 leetcode 263: Ugly Number
Ugly NumberTotal Accepted: 1849 Total Submissions: 5482Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only incl
2015-08-19 20:17:44
6376
原创 leetcode 258: Add Digits
Add DigitsTotal Accepted: 5383 Total Submissions: 11876Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 3
2015-08-19 20:16:18
7416
原创 leetcode 257: Binary Tree Paths
Binary Tree PathsTotal Accepted: 3755 Total Submissions: 17536Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3
2015-08-19 20:14:04
4355
原创 leetcode 240: Search a 2D Matrix II
leetcode 240: Search a 2D Matrix II python java c++
2015-07-23 06:07:35
14410
原创 leetcode 239: Sliding Window Maximum
leetcode 239: Sliding Window Maximumpython c++ java
2015-07-19 15:41:45
10266
原创 leetcode 238: Product of Array Except Self
leetcode 238: Product of Array Except Selfpython, c++ java
2015-07-16 14:40:04
12269
原创 leetcode 237: Delete Node in a Linked List
leetcode 237: Delete Node in a Linked ListPYTHON JAVA C++
2015-07-15 14:50:40
18480
1
原创 leetcode 234: Palindrome Linked List
leetcode 234: Palindrome Linked Listpython, java, c++
2015-07-14 04:40:25
8960
原创 leetcode 236: Lowest Common Ancestor of a Binary Tree
leetcode 236: Lowest Common Ancestor of a Binary TreePYTHON, JAVA, C++
2015-07-14 02:35:39
7542
原创 leetcode 235: Lowest Common Ancestor of a Binary Search Tree
leetcode 235: Lowest Common Ancestor of a Binary Search Treepython, java, c++
2015-07-11 06:34:08
12524
原创 leetcode 233: Number of Digit One
leetcode 233: Number of Digit Onejava python c++
2015-07-08 07:53:14
18163
1
原创 leetcode 230: Kth Smallest Element in a BST
leetcode 230: Kth Smallest Element in a BSTpython java c++
2015-07-07 06:14:58
10980
1
原创 leetcode 231: Power of Two
leetcode 231: Power of Twopython, java, c++
2015-07-07 05:01:24
12039
1
原创 leetcode 232:Implement Queue using Stacks
leetcode 232:Implement Queue using Stacks python java c++
2015-07-07 04:48:38
8123
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人