- 博客(19)
- 资源 (11)
- 收藏
- 关注
原创 【LeetCode从零单刷】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.解答:将一段有序序列转换为平衡二叉树,重要是递归。即中点作为根节点,小于部分作为左子树递归,大于部分作为右子树递归。这里的单链表给 “找中点” 造成了难题,
2015-11-28 21:42:54 927
原创 【LeetCode从零单刷】Reverse Bits
题目:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as001
2015-11-28 21:19:28 1555
原创 【LeetCode从零单刷】Merge Sorted Array
题目:Given two sorted integer arrays nums1 and nums2, merge nums2 intonums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal tom + n) to hol
2015-11-28 21:07:10 1287 1
原创 【LeetCode从零单刷】Kth Largest Element in an Array
题目:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, retur
2015-11-28 20:55:39 1400 1
原创 【LeetCode从零单刷】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.解答:非常无聊的一题。需要注意的是:叶子节点是自身不为 N
2015-11-28 20:24:35 1348 1
原创 【LeetCode从零单刷】Perfect Squares
题目:Given a positive integer n, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because12 = 4 + 4 + 4; given
2015-11-28 19:38:52 2103 2
原创 C/C++ 实现 atoi 函数
将一段字符串转换为整数数字,最基本的方法就是使用 atoi 函数。如果让我们自己实现一段 atoi 函数,需要注意的细节比较多。原始版本首先想到的就是字符类型之间的差值。可以直接使用字符相减得到差值。 int myAtoi(char* pstr){ int ans = pstr[0] - '0'; return ans;}看起来好像很简单,但是答案就是这样么?
2015-11-16 15:00:34 3680
原创 【LeetCode从零单刷】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 *.Example
2015-11-15 22:20:07 879
原创 【LeetCode从零单刷】Intersection of Two Linked Lists
题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘
2015-11-13 17:54:49 1398
原创 【LeetCode从零单刷】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 的阶乘末尾有多少个 0?其实也就是询问结果是10的多少倍数。10 = 2 * 5,因此对每个乘数进行因式分解就好。
2015-11-05 19:07:33 873
原创 【LeetCode从零单刷】Longest Increasing Subsequence
题目:Given an unsorted array of integers, find the length of longest increasing subsequence.For example, Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101],
2015-11-05 16:45:31 3156
原创 【LeetCode从零单刷】Longest Consecutive Sequence
题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,
2015-11-04 10:07:34 1458
原创 【LeetCode从零单刷】Search in Rotated Sorted Array I & II
I 题目: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 re
2015-11-02 23:18:12 1494
原创 【LeetCode从零单刷】Game of Life
题目:According to the Wikipedia's article: "The Game of Life, also known simply asLife, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board w
2015-11-02 21:53:00 1450
原创 【LeetCode从零单刷】Remove Duplicates from Sorted Array I & II
I 题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this in plac
2015-11-02 21:29:36 1388
原创 【LeetCode从零单刷】House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen
2015-11-02 21:03:07 1570
原创 【LeetCode从零单刷】Binary Tree Level Order Traversal I & II
题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9
2015-11-01 10:53:39 777
原创 【LeetCode从零单刷】H-index I & II
题目:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikip
2015-11-01 10:25:25 909
原创 【LeetCode从零单刷】Set Matrix Zeroes
题目:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward solution using O(mn) space is probabl
2015-11-01 09:38:57 1543
SPH 流体动画源代码
2014-11-24
邮箱地址列表语法分析(附实验报告)
2013-01-05
邮箱地址列表词法分析(附实验报告)
2013-01-04
邮箱地址列表词法分析(含实验报告)
2013-01-04
计算机网络(谢希仁著,第五版)
2012-09-28
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人