[LeetCode] Palindrome Partitioning II
Palindrome Partitioning II Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioni...
[LeetCode] Length of Last Word
Length of Last WordGiven a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not...
[LeetCode] Binary Tree Postorder Traversal
Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 &nbs...
[LeetCode] Spiral Matrix II
Spiral Matrix IIGiven an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following mat...
穿越时空的思念
犬夜叉的主题区,很好听。
[LeetCode] Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解题思路:可...
[LeetCode] Letter Combinations of a Phone Number
Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is...
[LeetCode] Plus One
Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.解题思路:这道题倒是挺简单的,但是我最开...
[LeetCode] Merge Two Sorted Lists
Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.解题思路:这道题是我做的leetcode最容易的题目了。其中有个小技巧,就...
将javascript对象转化成字符串
将javascript对象转化成字符串var obj = {arg1: value1} alert(JSON.stringify(obj));
[LeetCode] Valid Number
Valid NumberValidate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" =>&...
[LeetCode] Maximal Rectangle
Maximal Rectangle Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.解题思路;题意表示找到右全1形成的最大的矩形块。解法1:用动态规划做,若d[i][j]表示以matrix...
JavaScript数组功能扩展--差集,并集,合集,去重
//数组功能扩展 Array.prototype.each = function(fn){ fn = fn || Function.K; var a =&nb...
js 正则表达式
验证js字符串str是否满足正则表达式:/\{[^\}]*?\}/g.test(str);获得字符串str中的所有匹配:var matched = str.match(/\{[^\}]*?\}/g);上述中返回的是一个数组对象,若未匹配,matched=0。若匹配,则可以当做数组来遍历。
[LeetCode] Median of Two Sorted Arrays
Median of Two Sorted ArraysThere are two sorted arrays A and B 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)).解题思路:最基本的办...
[LeetCode]Find Minimum in Rotated Sorted Array
Find Minimum in Rotated Sorted ArraySuppose 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).Find the minimum element.Y...
[LeetCode] Spiral Matrix
Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ ...
面试知识点笔记
x=x&(x-1),表示去除x二进制表示的最后一个1位。很容易理解,x-1将最后一个1变成了0,然后与x按位与,新产生的1全变成0面试题:#include main() { int b = 3; int arr[] = {6,&nbs...
[LeetCode]Compare Version Numbers
Compare Version NumbersCompare two version numbers version1 and version2.If version1 > version2 return 1, if version1
[LeetCode OJ] Two Sum
Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, ...