自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Minimum Height Trees

题目: https://leetcode.com/problems/minimum-height-trees/ 思路: 所求结点为最长路径上的中间结点, 每次删除所有的叶子结点,多次删除后,最后剩下的就是中间结点class Solution {public: vector<int> findMinHeightTrees(int n, vector<pair<int, int>>& e

2015-11-29 20:02:35 247

原创 leetcode Path Sum II

题目:Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. 代码/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo

2015-11-27 12:00:21 233

原创 Median of Two Sorted Arrays

主要思想: 在两个数组中查找第k个元素时(k从1开始),若nums1[k/2-1]>nums2[k/2-1],这说明在数组nums2中,前k/2个元素(数组从nums2[0]开始)中肯定不包含第k个元素,将这前k/2个元素剔除,在num1和剩余的nums2元素中查找第k-k/2个元素.double find_the_Kth_element(int* nums1, i

2015-11-25 10:15:12 315

原创 Longest Substring Without Repeating Characters

题意: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3.

2015-11-19 13:01:00 272

原创 Two sum

题意: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2015-11-17 17:10:43 275

原创 Add Two Numbers

题意: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a

2015-11-17 13:38:03 245

原创 Different Ways to Add Parentheses

Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.// 后根遍历class Solu

2015-11-17 13:19:44 264

原创 Serialize and Deserialize Binary Tree

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

2015-11-16 20:38:42 221

原创 Palindrome Linked List

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bool isPalind

2015-11-16 19:02:53 222

原创 Find the Duplicate Number

int findDuplicate(int* nums, int numsSize) { int low=1; int high=numsSize-1; int mid; // answer_value 在[low,high]上 while(true){ mid=(low+high)/2; int smaller=0;

2015-11-16 19:01:23 222

原创 Lowest Common Ancestor of a Binary Tree

Lowest Common Ancestor of a Binary Tree/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), lef

2015-11-12 21:38:01 239

空空如也

空空如也

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

TA关注的人

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