自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 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-04-29 15:14:01 280

转载 Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].// RECURSIVE VERSION:

2014-04-28 15:47:39 330

转载 Best Time to Buy and Sell Stock

class Solution {public:    int maxProfit(vector &prices) {        // Note: The Solution object is instantiated only once and is reused by each test case.        int solution = 0;         

2014-04-28 15:10:46 403

转载 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.class Solution {publ

2014-04-28 15:02:05 326

转载 Generate Parentheses

void helper(vector & solution, string & singleSolution,                int numofleft, int numofright, int n){        if (singleSolution.size()==(2*n))            solution.push_back(singleSolutio

2014-04-28 14:43:52 298

转载 Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},

2014-04-28 14:19:42 185

转载 Permutations

// NON-SWAP VERSION:class Solution {public:    vector > solution;    vector singleSolution;        void helper(vector & num, vector & visited){        if (singleSolution.size()==num.size

2014-04-28 13:54:18 318

转载 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-04-28 13:13:40 284

转载 Gray Code

class Solution {public:    vector grayCode(int n) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        vector result;              result.pu

2014-04-28 13:10:12 280

转载 Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f

2014-04-28 09:47:31 337

转载 Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2014-04-28 09:10:55 319

转载 Pascal's Triangle

For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]

2014-04-28 08:53:23 318

转载 Integer to Roman

class Solution {public:    string intToRoman(int num) {        // Note: The Solution object is instantiated only once and is reused by each test case.            string solution = "";       

2014-04-28 08:38:34 339

转载 Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution {public:    int romanToInt(string s) {        // Note: The Solution

2014-04-28 08:37:23 332

转载 Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.

2014-04-28 07:45:50 305

转载 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?class Solution {public: 

2014-04-28 06:37:56 348

转载 Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.

2014-04-28 06:27:29 309

转载 Populating Next Right Pointers in Each Node

/** * Definition for binary tree with next pointer. * struct TreeLinkNode { *  int val; *  TreeLinkNode *left, *right, *next; *  TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(N

2014-04-28 05:47:09 418

转载 Single Number II

Given 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. Could you implement it without usi

2014-04-28 05:30:52 308

转载 Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.

2014-04-28 04:56:43 282

转载 Best Time to Buy and Sell Stock II

class Solution {public: int maxProfit(vector &prices) { // Start typing your C/C++ solution below // DO NOT write int main() function int p = 0; for(int i = 1; i

2014-04-27 13:25:01 366

转载 Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?

2014-04-27 13:22:01 294

转载 Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.

2014-04-27 13:15:09 265

转载 Same Tree

/** * Definition for binary tree * struct TreeNode { *     int val; *     TreeNode *left; *     TreeNode *right; *     TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla

2014-04-27 13:11:29 350

转载 Maximum Depth of Binary Tree

/** * Definition for binary tree * struct TreeNode { *     int val; *     TreeNode *left; *     TreeNode *right; *     TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla

2014-04-27 13:09:30 290

转载 Single Number

Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using e

2014-04-27 13:06:32 267

转载 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321

2014-04-27 13:04:45 250

转载 Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values./** * Definition for binary tree * struct TreeNode { *     int val; *     TreeNode *left; *     TreeNode *righ

2014-04-27 12:58:20 270

转载 Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solutio

2014-04-27 12:54:24 295

空空如也

空空如也

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

TA关注的人

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