自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [Leetcode]Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Re

2014-10-07 11:39:40 314

原创 [Leetcode] Spiral Matrix

switch the direction, it'a very straight solution but it's more "algorithm" than using

2014-08-28 09:00:16 301

原创 [Leetcode] Binary Tree Level Order Traversal

traverse the binary tree from left to right, from top to bottom:

2014-08-28 07:06:51 339

原创 [Leetcode]Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.There are more than one zero elements in the

2014-08-28 03:43:41 373

原创 [Leetcode] Postorder Traverse of Binary Tree

Method 1: two stacks /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class

2014-08-27 22:06:33 491

原创 [Leetcode]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,

2014-08-20 04:47:50 354

原创 [Leetcode]Best Time to Buy and Sell Stock

public class Solution { public int maxProfit(int[] prices) { //int ans = 0; if(prices.length <= 1) return 0; int profit = 0; int min = prices[0]; for (int i = 0; i <

2014-08-19 02:04:37 362

原创 [Leetcode] Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2014-08-18 22:37:55 383

原创 [Leetcode] Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each

2014-08-17 04:53:41 347

原创 [Leetcode] Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the

2014-08-15 04:58:16 303

原创 [Leetcode] Permutations

Given a collection of numbers, return all possible permutations.

2014-08-14 23:47:50 311

原创 [Leetcode] Plus One

Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.public class Solutio

2014-08-14 04:38:55 332

原创 [Leetcode] Rotate Matrix

Rotate a matrix for 90 degree in clockwise. public void rotate(int[][] matrix) { int n = matrix[0].length; for (int i = 0; i < Math.floor(n/2) ; i++) { for (int j = i; j < n-1-i; j+

2014-08-13 23:11:48 595

原创 [Leetcode] Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

2014-08-13 20:44:23 376

原创 [leetcode] 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

2014-08-12 22:51:53 373

空空如也

空空如也

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

TA关注的人

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