自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(63)
  • 收藏
  • 关注

原创 518. Coin Change 2

You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite numbe

2017-06-25 07:28:06 1755

原创 85. Maximal Rectangle

Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1

2017-06-24 13:20:37 245

原创 480. Sliding Window Median

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median

2017-06-23 16:23:16 320

原创 239. Sliding Window Maximum

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window

2017-06-23 14:05:15 299

原创 84. Largest Rectangle in Histogram

Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width o

2017-06-23 13:19:31 311

原创 212. Word Search II

Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those hor

2017-06-23 01:58:09 306

原创 295. Find Median from Data Stream

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median

2017-06-22 01:24:03 234

原创 407. Trapping Rain Water II

Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:Both m and n are l

2017-06-21 08:28:51 256

原创 42. Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1

2017-06-20 06:21:39 266

原创 388. Longest Absolute File Path

Suppose we abstract our file system by a string in the following manner:The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents:dir subdir1 subdir2 file.extThe direc

2017-06-19 14:10:37 242

原创 146. LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of the key i

2017-06-19 12:38:16 402

原创 560. Subarray Sum Equals K

Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2Output: 2Note:

2017-06-17 13:34:13 389

原创 398. Random Pick Index

Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The array size c

2017-06-17 13:16:05 255

原创 382. Linked List Random Node

Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.Follow up:What if the linked list is extremely large and i

2017-06-17 13:01:00 234

原创 307. Range Sum Query - Mutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at index i to val.Examp

2017-06-17 09:00:34 297

原创 604. Design Compressed String Iterator

Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext.The given compressed string will be in the form of each letter

2017-06-17 02:05:11 507

原创 353. Design Snake Game

Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game.The snake is initially positioned at the top left cor

2017-06-16 16:41:06 636

原创 379. Design Phone Directory

Design a Phone Directory which supports the following operations:get: Provide a number which is not assigned to anyone.check: Check if a number is available or not.release: Recycle or release

2017-06-16 14:54:07 374

原创 348. Design Tic-Tac-Toe

Design a Tic-tac-toe game that is played between two players on a n x n grid.You may assume the following rules:A move is guaranteed to be valid and is placed on an empty block.Once a winning

2017-06-16 11:43:13 334

原创 362. Design Hit Counter

Design a hit counter which counts the number of hits received in the past 5 minutes.Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being mad

2017-06-16 09:16:45 345

原创 251. Flatten 2D Vector

Implement an iterator to flatten a 2d vector.For example,Given 2d vector = [ [1,2], [3], [4,5,6]]By calling next repeatedly until hasNext returns false, the order of elements r

2017-06-16 03:18:53 310

原创 284. Peeking Iterator

Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek()operation -- it essentially peek() at the element that will be r

2017-06-16 01:48:05 320

原创 281. Zigzag Iterator

Given two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 = [3, 4, 5, 6]By calling next repeatedly until hasNext 

2017-06-15 15:29:30 315

原创 444. Sequence Reconstruction

Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. Reconstruction me

2017-06-15 12:16:15 987

原创 399. Evaluate Division

Equations are given in the format A / B = k, where  A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the ans

2017-06-15 06:43:26 319

原创 310. Minimum Height Trees

For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini

2017-06-15 03:15:04 271

原创 286. Walls and Gates

You are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to repr

2017-06-15 01:53:46 333

原创 130. 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,

2017-06-14 12:30:41 248

原创 529. Minesweeper

Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. 'M' represents an unrevealed mine, 'E' represents an unrevealed empty squa

2017-06-14 10:51:59 318

原创 533. Lonely Pixel II

Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific row Rand column C that align with all the following rules:

2017-06-14 08:19:07 1608

原创 531. Lonely Pixel I

Given a picture consisting of black and white pixels, find the number of black lonely pixels.The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pi

2017-06-14 04:41:52 426

原创 542. 01 Matrix

Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1.Example 1: Input:0 0 00 1 00 0 0Output:0 0 00 1 00

2017-06-14 03:02:37 388

原创 547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, the

2017-06-14 01:33:53 240

原创 491. Increasing Subsequences

Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .Example:In

2017-06-13 12:54:58 314

原创 473. Matchsticks to Square

Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You shoul

2017-06-13 12:04:46 281

原创 505. The Maze II

There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, i

2017-06-10 08:02:50 718

原创 490. The Maze

There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, i

2017-06-10 07:58:27 886

原创 323. Number of Connected Components in an Undirected Graph

Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.Example 1:

2017-06-10 05:27:06 555

原创 261. Graph Valid Tree

Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.For example:Given n =

2017-06-10 05:08:42 321

原创 417. Pacific Atlantic Water Flow

Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" tou

2017-06-08 14:18:47 243

空空如也

空空如也

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

TA关注的人

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