- 博客(27)
- 收藏
- 关注
原创 LeetCode.112(113/437) Path Sum I && II && III
题目112: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 t
2017-12-29 23:09:57 178
原创 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 number123.Find the
2017-12-29 22:24:56 98
原创 LeetCode.106 Construct Binary Tree from Inorder and Postorder Traversal
题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.分析1(原创):/** * Definition for a binary tree
2017-12-29 21:50:05 121
原创 LeetCode.105 Construct Binary Tree from Preorder and Inorder Traversal
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.分析1(原创):/** * Definition for a binary tree
2017-12-29 21:11:04 106
原创 LeetCode.104(107) Maximum(Minimum) Depth of Binary
题目104: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
2017-12-28 11:51:31 92
转载 KNN和K-means区别
Kmeans(K均值)与Kmeans++和KNN(K近邻)算法比较 原创 2013年11月28日 09:11:34 标签:
2017-12-27 21:37:43 981
原创 LeetCode.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.For this problem, a height-balanced binary tree is defined as a binary tree in whi
2017-12-27 17:22:18 95
原创 LeetCode.102(107) Binary Tree Level Order Traversal I&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,nu
2017-12-24 13:55:55 140
原创 LeetCode.343 Integer Break
题目:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n
2017-12-23 23:39:16 99
原创 LeetCode.345 Reverse Vowels of a String
题目:Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".N
2017-12-23 15:16:00 126
原创 LeetCode.228 Summary Ranges
题目:Given a sorted integer array without duplicates, return the summary of its ranges.Example 1:Input: [0,1,2,4,5,7]Output: ["0->2","4->5","7"]Example 2:Input: [0,2,3,4,6,8,9]Outpu
2017-12-22 21:54:33 134
原创 LeetCode.462 Equal Array Elements II
题目:Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected el
2017-12-21 22:07:50 178
原创 LeetCode.240 Search a 2D Matrix II
题目: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 in ascending from left to right.Int
2017-12-21 20:55:38 99
原创 LeetCode.419 Arithmetic Slices
题目:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmeti
2017-12-19 11:34:56 182
原创 LeetCode.200 Number of Islands
题目:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You
2017-12-13 16:31:32 150
原创 LeetCode.199 Binary Tree Right Side View
题目:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree
2017-12-13 00:24:31 103
原创 LeetCode.151 Reverse Words in a String(单词切分和List转成数组)
题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in
2017-12-11 15:26:12 115
原创 LeetCode.178 Rank Scores
题目:Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive intege
2017-12-11 10:19:57 238
原创 LeetCode.176 Second Highest Salary (Limit偏移量运用)
题目:Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+
2017-12-06 20:57:38 178
原创 LeetCode.56 Merge Intervals
题目: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].分析:/** * Definition for an interval.
2017-12-06 19:33:33 141
原创 LeetCode.739 Daily Temperatures
题目:Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for
2017-12-06 11:09:12 1188
原创 LeetCode.192(461/477) Number 1 Bits & Hamming Distance & Total Hamming Dist(经典位运算应用,求解二进制其中1的个数)
题目192:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit integer ’11' has binary representation 0000000...
2017-12-03 11:31:32 158
原创 LeetCode.537 Complex Number Multiplication
题目:Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1+1i", "1+
2017-12-02 22:43:40 132
原创 LeetCode.322(518) Coin Change && Coin Change2
题目322:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of ...
2017-12-02 22:01:10 182
原创 LeetCode.520 Detect Capital
题目:Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All let
2017-12-01 15:29:42 168
原创 LeetCode.729 My Calendar I
题目:Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking.Your class will have the method, book(int start, int end)
2017-12-01 14:58:19 243
原创 LeetCode.643 Maximum Average Subarray I
题目:Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.Example 1:
2017-12-01 10:20:34 234
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人