自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

西施豆腐渣

leetcode solutions by java, c++ and python

  • 博客(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 4399

原创 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 5462

原创 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 3567

原创 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 4243

原创 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 6499

原创 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 7122 1

原创 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 6643

原创 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 9338

原创 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 6599

原创 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 8636 6

原创 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 5222

原创 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 6387

原创 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 7449

原创 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 6479

原创 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 6158

原创 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 7930 5

原创 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 6872

原创 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 4935

原创 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 8393

原创 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 9184

原创 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 2827

原创 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 5050 3

原创 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 3162

原创 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 4144

原创 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 6005

原创 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 6281

原创 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 7382 2

原创 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 4295 1

原创 leetcode 242: Valid Anagram

leetcode 242: Valid Anagrampython java c++

2015-08-02 15:57:10 7481

原创 leetcode 240: Search a 2D Matrix II

leetcode 240: Search a 2D Matrix II python java c++

2015-07-23 06:07:35 14282 3

原创 leetcode 239: Sliding Window Maximum

leetcode 239: Sliding Window Maximumpython c++ java

2015-07-19 15:41:45 10148

原创 leetcode 238: Product of Array Except Self

leetcode 238: Product of Array Except Selfpython, c++ java

2015-07-16 14:40:04 12193

原创 leetcode 237: Delete Node in a Linked List

leetcode 237: Delete Node in a Linked ListPYTHON JAVA C++

2015-07-15 14:50:40 18304 3

原创 leetcode 234: Palindrome Linked List

leetcode 234: Palindrome Linked Listpython, java, c++

2015-07-14 04:40:25 8888

原创 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 7461 1

原创 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 12388 8

原创 leetcode 233: Number of Digit One

leetcode 233: Number of Digit Onejava python c++

2015-07-08 07:53:14 18049 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 10904 2

原创 leetcode 231: Power of Two

leetcode 231: Power of Twopython, java, c++

2015-07-07 05:01:24 11941 2

原创 leetcode 232:Implement Queue using Stacks

leetcode 232:Implement Queue using Stacks python java c++

2015-07-07 04:48:38 8068 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除