- 博客(11)
- 收藏
- 关注
原创 Additive number
Additive number is a positive integer whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent num
2015-11-18 20:33:44 531
原创 Same Tree
Same TreeSep 3 '12Given 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
2015-11-16 20:05:57 323
原创 Range Sum Query 2D - Immutable
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).The above rectangle (with the red bo
2015-11-15 18:03:47 355
原创 段错误调试
我们在用C/C++语言写程序的时侯,内存管理的绝大部分工作都是需要我们来做的。实际上,内存管理是一个比较繁琐的工作,无论你多高明,经验多丰富,难 免会在此处犯些小错误,而通常这些错误又是那么的浅显而易于消除。但是手工“除虫”(debug),往往是效率低下且让人厌烦的,本文将就"段错误"这个 内存访问越界的错误谈谈如何快速定位这些"段错误"的语句。下面将就以下的一个存在段错误的程序介绍几种调试方
2015-11-12 10:46:28 760
原创 Wildcard Matching
isMatch("aa","a") → falseisMatch("aa","aa") → trueisMatch("aaa","aa") → falseisMatch("aa", "*") → trueisMatch("aa", "a*") → trueisMatch("ab", "?*") → trueisMatch("aab", "c*a*b") → falsebool
2015-11-10 20:06:33 310
原创 Range Sum Query - Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan
2015-11-10 20:00:52 404
转载 LeetCode-Valid Number - 有限状态机
判断合法数字用有限状态机,非常简洁,不需要复杂的各种判断!先枚举一下各种合法的输入情况:1.空格+ 数字 +空格2.空格+ 点 + 数字 +空格3.空格+ 符号 + 数字 + 空格4.空格 + 符号 + 点 + 数字 +空格5.空格 + (1, 2, 3, 4) + e + (1, 2, 3, 4) +空格组后合法的字符可以是:
2015-11-05 17:48:22 295
原创 Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc",
2015-11-04 20:31:09 274
原创 Palindrome Partitioning I,II(DFS,DP)
分析:题意给我们一个字符串,求出所有这个字符串的子串,并且子串都为回文字符串的情况,输出它的集合结果解题思路:(跟DFS深度遍历有点像!)字符串Str = "aab";分析了题目的数据之后,我们知道它的结果,可能是 a, a, b 或者 aa, b 这样的情况!也就是说,我们需要去考虑 i = 1, 2 .... n 的情况,比如Str = "
2015-11-04 20:28:10 270
原创 Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0
2015-11-03 21:59:11 267
原创 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [
2015-11-01 19:22:03 280
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人