自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [leetcode][java]Merge Two Sorted Lists 合并两个排序的链表

递归: public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if (l1 == null) { return l2; } if (l2 == null) { return l1;

2017-03-26 22:24:21 235

原创 [leetcode]Binary Tree Maximum Path Sum

题目描述:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3R

2014-08-31 16:58:30 221

原创 ArrayList删除指定元素

当使用ArrayList删除指定的某些元素时,想到的最直观的方法是调用remov

2014-08-18 11:51:22 632 1

原创 [leetcode]Surrounded Regions

题目描述:Given a 2D board containing 'X' and '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,X X

2014-08-18 11:26:00 256

原创 [leetcode]Multiply Strings

题目描述:Given two numbers represented as strings, return multiplication of the numbers as a string.分析

2014-06-24 11:31:20 180

原创 [leetcode]Jump Game &&Jump Game II

题目描述:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.

2014-06-12 22:04:09 222

原创 [leetcode]Surrounded Regions

题目描述:Given a 2D board containing 'X' and '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,X X

2014-06-12 11:32:34 223

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

2014-06-12 10:44:08 233

原创 [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.思路:

2014-06-09 16:54:53 249

原创 [leetcode]Minimum Path Sum

思路:基础动态规划问题f代码:class Solution {public: int minPathSum(vector > &grid) { int m=grid.size(); int n=grid[0].size(); int f[m][n]; f[0][0]=grid[0][0]; f

2014-06-05 17:36:14 191

原创 [leetcode]Reorder List

题目描述:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reo

2014-06-04 17:02:15 220

原创 [leetcode]Path Sum&&Path Sum II(剑指offer面试题25)

题目描述:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tr

2014-06-04 12:04:09 236

原创 [leetcode]Minimum Depth of Binary Tree

题目描述:求二叉树的最小深度,即从根节点到yejiedian

2014-06-04 11:57:53 314

原创 [leetcode]Palindrome Partitioning

题目描述:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [

2014-05-30 22:46:16 201

原创 [leetcode]Flatten Binary Tree to Linked List

题目描述:Given a binary tree, flatten it to a linked list in-place.思路:遍历二叉树,将

2014-05-26 22:55:58 189

原创 [leetcode]Pow(x, n)&&Sqrt(x)

Pow(x,n) 求x的n次方。需要用到分治法,把x的n次方hu

2014-05-22 11:12:26 300

原创 [leetcode]Edit Distance

编辑距离问题,典型的动态规划解决的问题。

2014-05-07 21:02:55 206

原创 [leetcode]Spiral Matrix&&Spiral Matrix II

Spiral Matrix 给定一个m*n的矩阵,按照顺时针方向,返回螺旋方向上的元素列表。

2014-05-07 20:48:14 317

原创 [Leetcode]Sudoku Solver&&Valid Sudoku

数独游戏。规则很简单,每行

2014-04-09 18:13:33 302

原创 Best Time to Buy and Sell Stock

第一题:只有一次股票交易,从第一个开始设为min,遍历过程中每次比较更新min值,同时计算股票收益,比较之前的股票收益,最大的即为最大收益。Best Time to Buy and Sell Stock class Solution {public: int maxProfit(vector &prices) { int max=0; in

2014-03-26 22:03:05 239

原创 Copy List with Random Pointer

剑指offer上的题目,实现也是按照书上的方法。/** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNode(i

2014-03-24 19:59:02 209

原创 二叉树的非递归前序、中序、后序遍历

递归的前序、中序、后序遍历与概念基本一致,简单明了。而非递归遍历稍微麻烦,确实最容易被问到的东西。首先看非递归前序遍历:用栈实现,先访问根节点,然后压入右子树,再压入左子树。Binary Tree Preorder Traversal /** * Definition for binary tree * struct TreeNode { * int va

2014-03-24 19:49:24 256

原创 Construct Binary Tree from Inorder and Preorder(Postorder) Traversal

通过前序中序序列构造二叉树以及通过后序中序序列构造二叉树。用递归,每次通过寻找根节点,改变peorder和inorder的起止位置,实现递归。前序中序序列构造二叉树代码:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNo

2014-03-19 20:49:25 335

原创 Search a 2D Matrix

观察矩阵规律,从右上角开始找,根据比较结果向下或者向左遍历。class Solution {public: bool searchMatrix(vector > &matrix, int target) { int m=matrix.size(); int n=matrix[0].size(); if(m==0||n==0){

2014-03-19 11:55:09 284

原创 Reverse Words in a String

字符串处理应该属class Solution {public: void reverseWords(string &s) { if(s==""){ return; } s=s+" "; string str=""; string ret=""; int flag=1; for(

2014-03-19 11:46:01 307

空空如也

空空如也

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

TA关注的人

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