leetcode解题报告
文章平均质量分 57
骨头骨头骨头
这个作者很懒,什么都没留下…
展开
-
leetcode:273. Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For example, 123 -> "One Hundred Twenty Three" 12345 -> "Twelve Thousand Th原创 2016-02-22 22:35:31 · 264 阅读 · 0 评论 -
leetcode:268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm shoul原创 2016-07-03 16:46:37 · 204 阅读 · 0 评论 -
leetCode:2. 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 link原创 2016-07-12 13:23:35 · 246 阅读 · 0 评论 -
leetcode:290. Word Pattern
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.原创 2016-06-06 19:04:07 · 238 阅读 · 0 评论 -
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 va原创 2016-06-06 10:21:30 · 165 阅读 · 0 评论 -
leetcode:60. Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123""132""213""231""3原创 2016-06-10 22:58:10 · 245 阅读 · 0 评论 -
leetcode:338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array. Example: For num = 5原创 2016-06-03 11:05:38 · 213 阅读 · 0 评论 -
leetcode: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 \原创 2016-06-01 10:09:50 · 211 阅读 · 0 评论 -
leetcode:226. Invert 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原创 2016-02-17 01:06:08 · 300 阅读 · 0 评论 -
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. Subscribe to see which compani原创 2016-02-17 00:21:41 · 209 阅读 · 0 评论 -
leetcode:152. Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the la原创 2016-02-19 03:11:12 · 214 阅读 · 0 评论 -
leetcode: 172. Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. n!质因数分解中,2的次幂一定大于5的次幂,所以0的个数取决于5的次幂有多少 代码 class Solution {原创 2016-02-19 14:06:37 · 188 阅读 · 0 评论 -
leetcode:1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given nums =原创 2016-07-06 10:21:11 · 226 阅读 · 0 评论