- 博客(18)
- 收藏
- 关注
原创 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 254
原创 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 243
原创 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 216
原创 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)).Example 1:nums1 =
2016-07-02 01:41:30 287 1
原创 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 251
原创 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 249
原创 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 175
原创 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 227
原创 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 221
原创 随笔1:shell递归遍历文件夹
最近工作需要,写了一些shell脚本用来做服务器一键打包更新,1)通过for递归遍历文件夹时文件名中含有空格解决方式:修改分隔#! /bin/bashfunction dfs{ old_IFS=${IFS} IFS=$(echo -e '\n') for file in `ls -A "$1"` do if [ -d $1/${file} ]; the
2016-05-17 20:10:51 1532
原创 【从下而上学习Redis】数据结构篇(一):跳跃表(skiplist)
描述跳跃表(skiplist)是对有序的链表增加上附加的前进链接,增加是以随机化的方式进行的,所以在列表中的查找可以快速的跳过部分列表(因此得名)。
2016-04-23 14:17:59 702
原创 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 274
原创 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 198
原创 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 223
原创 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 311
原创 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 219
原创 《剑指offer》 学习笔记(二): 二维数组中的查找
面试题3:二维数组中的查找题目描述:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为两个整数m和n(1输入的第二行包括一个整数t(1接下来的m行,每行有n个数,代表题目所给出的m行n
2016-02-14 22:45:29 314
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人