- 博客(240)
- 资源 (20)
- 收藏
- 关注
原创 Leetcode[129]-Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of al
2015-06-12 14:15:32 938
原创 LeetCode[155]-Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the
2015-06-12 08:56:37 996
原创 Leetcode[101]-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 3 But the following is not
2015-06-11 23:00:32 850
原创 Leetcode[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.递归法:/** * Definition for a binary tree nod
2015-06-11 22:23:13 952
原创 Leetcode[94]-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].递归遍历法:/** * Definition for a binary tree node
2015-06-11 20:23:17 864
原创 Leetcode[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.思路:递归法判断 假设两棵树根结点为
2015-06-11 18:16:33 840
原创 Leetcode[104]-Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.求最大深度,用递归的方法/** * Definition for a binary
2015-06-11 17:17:45 854
原创 Leetcode[20]-Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid but "
2015-06-11 14:45:26 820
原创 Leetcode[125]-Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindr
2015-06-11 14:12:35 916
原创 Leetcode[222]-Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and
2015-06-11 13:24:18 2117
原创 Leetcode[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 is
2015-06-11 12:18:43 698
原创 Leetcode[4]-Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路:先将两个数组合并,然后排序,最后找中位数中位数:若有n
2015-06-11 12:09:40 649
原创 Leetcode[154]-Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed?Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at some pivot unknown to y
2015-06-11 11:04:25 794
原创 Leetcode[153]-Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in the array.方法一:直
2015-06-11 10:59:50 986
原创 Leetcode[162]-Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in that case
2015-06-11 10:56:12 1405
原创 Leetcode[81]-Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in the ar
2015-06-11 10:36:08 829
原创 Leetcode[33]-Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index
2015-06-11 10:17:51 1192
原创 Leetcode[35]-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.Here
2015-06-11 09:07:15 575
原创 Leetcode[92]-Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the following co
2015-06-10 22:41:01 701
原创 Leetcode[147]-Insertion Sort List
Sort a linked list using insertion sort.链表的插入排序思路:新开辟一个链表空间,用来作为插入排序的目标链。循环遍历原链表,对每个节点,让其从头到尾的在已经排好序的链表中找到插入位置(此处记录的是插入位置的前一个位置),然后将其插入进去即可。代码Code(c++):/** * Definition for singly-linked list. * stru
2015-06-10 21:23:29 655
原创 Leetcode[82]-Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, return1->2->5. Given 1->1->1->2-
2015-06-10 20:33:01 783
原创 Leetcode[83]-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. 比较简单,直接贴代码了!/** * Definition for
2015-06-10 20:06:51 765
原创 Leetcode[19]-Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked l
2015-06-10 19:58:39 766
原创 Leetcode[143]-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}, reorder it to {1,4,2,3}
2015-06-10 18:57:41 1500
原创 Leetcode[86]-Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the
2015-06-10 14:08:35 1159
原创 Leetcode[21]-Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路:要求合并两个排好序的链表。开始我们初始化头front和尾tail,然后从两个单链表的头部比较两个单链表,两链表同时
2015-06-10 13:37:11 1050
原创 Leetcode[148]-Sort List
Sort a linked list in O(n log n) time using constant space complexity.分析:题目要求时间复杂度为O(nlogn),所以一开始想到的就是快速排序,但是快速排序一直AC不了,然后就想到用归并排序,没想到归并排序竟然可以。下面给出详细代码:归并排序需要做的 找到中间点 合并两个排好序的链表 递归实现归并排序 Code(c++):/**
2015-06-10 13:23:21 934
原创 Leetcode[141]-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?分析:设置两个临时指针,一个一次走一步,一个一次走两步,如果再次相遇,表示有环。Code(c++):/** * Definition for singly-linked list.
2015-06-10 11:08:51 1252
原创 Leetcode[203]-Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5Credits: Special thanks to @mithmatt for a
2015-06-10 10:22:16 762
原创 Leetcode[206]-Reverse Linked List
Reverse a singly linked list.Reverse a singly linked list.Hint: A linked list can be reversed either iteratively or recursively. Could you implement both?分析: /** * Definition for singly-linked list.
2015-06-10 09:53:28 947
原创 Leetcode[202]-Happy Number
Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of i
2015-06-09 22:30:10 3560
原创 Leetcode[136]-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 extra me
2015-06-09 21:44:56 705
原创 Leetcode[36]-Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. A partially filled sudoku whic
2015-06-09 21:09:12 641
原创 Leetcode[18]-4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: Elements in a quad
2015-06-09 19:21:18 597
原创 Leetcode[15]-3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: Elements in a triplet (a,b,c) must be i
2015-06-09 18:46:54 871
原创 Leetcode[1]-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, where in
2015-06-09 16:40:29 829
原创 Leetcode[66]-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.题意:给定一个数组,表示的是非负数的各个位的数,现在将该数
2015-06-09 15:54:09 998
原创 Leetcode[219]-Contains Duplicate II
Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.分析:用m
2015-06-09 15:28:46 1130
原创 Leetcode[169]-Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always
2015-06-09 14:06:28 1138
原创 Leetcode[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 additional
2015-06-09 13:13:13 986
visio_2010_64位.part3.rar
2018-04-29
visio 2010 64 bit-part2
2018-04-29
visio 2010 64 bit-part1
2018-04-29
visio 2010 64 bit-part4
2018-04-29
决策树算法python实现
2015-05-25
python2.7.5安装及其相应的matplotlib的包及依赖
2015-05-25
jQuery+Struts+Ajax无刷新分页
2015-04-13
The Swift Programming Language - Apple Inc(英文版).pdf
2014-06-03
jasperreports-5.5.1_struts2.3整合用到的jar包
2014-05-28
php-5.3.6-Win32-VC9-x64.zip
2014-03-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人