自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(64)
  • 资源 (3)
  • 收藏
  • 关注

原创 138-Copy List with Random Pointer

题目A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.分析复制每一个节点,复制后的节点放在原节点之后更新Random 指针

2017-07-19 10:29:53 289

原创 217-Contains Duplicate

题目Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element i

2017-06-25 18:47:34 229

原创 141-Linked List Cycle

题目Given a linked list, determine if it has a cycle in it.分析快慢指针,当快指针追上慢指针,说明链表成环实现class Solution {public: bool hasCycle(ListNode *head) { if (head == NULL|| head->next == NULL)

2017-06-25 18:47:19 226

原创 132-Palindrome Partitioning II

题目Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”, Return 1 sinc

2017-06-25 18:46:51 228

原创 131-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[ [“aa”,”b”], [“a”

2017-06-25 18:46:35 196

原创 123-Best Time to Buy and Sell Stock III

题目Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may not eng

2017-06-25 18:46:03 181

原创 121-Best Time to Buy and Sell Stock

题目Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), de

2017-06-25 18:45:47 333

原创 120-Triangle

题目Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7],

2017-06-25 18:45:27 169

原创 114- Flatten Binary Tree to Linked List

题目Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2

2017-06-25 18:44:55 267

原创 112- Path Sum

题目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 tree and sum =

2017-06-25 18:44:33 280

原创 111- Minimum Depth of Binary Tree

题目Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.分析该问题是判断根节点到叶子结点的最小深度。不同于判断最大深度,当根节点的其中一个

2017-06-25 18:43:54 214

原创 109-Convert Sorted List to Binary Search Tree

题目Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.分析这个和Covert Sorted Array to Binary Search Tree 其实是类似的,都是通过递归构造关键就在于如何找到链表的中间结点。链表的中间结点可以用快

2017-06-25 18:43:03 196

原创 108-Convert Sorted Array to Binary Search Tree

题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析每次选择中间的那个数字d实现class Solution {public: //108. Convert Sorted Array to Binary Search Tree Tre

2017-06-25 18:41:41 178

原创 103-Binary Tree Zigzag Level Order Traversal

题目Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example: Given binary tre

2017-06-25 18:41:11 194

原创 102-Binary Tree Level Order Traversal

题目Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 /

2017-06-25 18:40:37 190

原创 100-Same Tree

题目Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.分析两个树相等,判断条件是 1.

2017-06-25 18:40:04 203

原创 98_ValidateBinarySearchTree

题目Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The rig

2017-06-25 18:39:19 204

原创 96-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. 1 3 3 2 1 \ /

2017-06-25 18:38:05 299

原创 95-Unique Binary Search Trees II

题目Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should return all 5 unique BST’s shown below. 1

2017-06-25 18:37:49 185

原创 94-Binary Tree Inorder Traversal

题目:Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3],1 \ 2 / 3return [1,3,2].分析: 二叉树的中序遍历 思路1: 递归 思路2: 用S

2017-06-25 18:36:23 193

原创 91-DecodeWays

题目A message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the total number

2017-06-25 18:35:43 148

原创 90-Subsets II

题目Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,2], a solution i

2017-06-23 15:50:34 182

原创 88-Merge Sorted Array

题目Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold addition

2017-06-23 15:50:19 153

原创 79-Word Search

题目Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically ne

2017-06-23 15:49:59 163

原创 78-Subsets

题目Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution is:[ [3], [1], [2], [

2017-06-23 15:39:28 143

原创 75-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 0,

2017-06-23 15:39:07 196

原创 74-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 row

2017-06-23 15:38:47 155

原创 73-Set Matrix Zeros

题目Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.分析方法一自己的思路,用两个数组分别记录行、列哪个为零方法二是参考的别人的代码,直接用数组的第一行和第一列记录,但是会有点麻烦,需要用一个额外的变量存储,有点不太好理解,所以自己写了一个方法一实现class

2017-06-23 15:38:29 316

原创 70-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?Note: Given n will be a positive in

2017-06-23 15:38:09 168

原创 69-Sqrt(x)

题目Implement int sqrt(int x).Compute and return the square root of x.分析这个题里面是有许多陷阱的 - 首先确定用二分法处理这个问题 - 然而0-x之间的num的平方有可能会溢出,所以不要使用num*num,如果使用的话要用long long 存储 - 还有left 不能为0,如果mid 也为零的话,x/mid 就会出错误 -

2017-06-23 15:37:43 3592

原创 66-Plus One

题目Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are

2017-06-23 15:37:25 252

原创 64-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 an

2017-06-23 15:36:42 159

原创 63-Unique Paths II

题目Follow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.For

2017-06-23 15:36:18 507 1

原创 62-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 bot

2017-06-23 15:36:01 174

原创 61-Rotate List

题目Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->NULLand k = 2, return 4->5->1->2->3->NULL.分析方法的思路是遍历一遍找到尾结点,并记录链表长度,然后连接成一个环,再遍历一遍找

2017-06-23 15:35:44 143

原创 56-Merge Intervals && 57-Insert Interval

题目56题 Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].57 题 Given a set of non-overlapping intervals, inse

2017-06-23 15:35:27 199

原创 55-Jump Game

题目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.Determine if you a

2017-06-23 15:35:11 136

原创 54-Spiral Matrix

题目Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You

2017-06-23 15:34:54 170

原创 53-Maximum Subarray

题目Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has t

2017-06-23 15:34:13 147

原创 52-N Queens II

题目:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.分析:和之前的题目一样,只是结果要求返回解的个数。 于是原来的vector代码:class Solution {public: int to

2017-06-23 15:33:54 135

SIFT ComputerVision Matlab2014a

特征提取 Computer Vision 可以直接运行的

2015-03-26

Normalized Cuts Matlab实现

计算机视觉 Normalized Cut and Image Segmentation

2015-03-26

栈和队列的实现

分别用不同的形式实现了栈和队列,具体的请大家自己看一下。

2013-10-22

空空如也

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

TA关注的人

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