将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, ...
[LeetCode] Decode Ways
Decode WaysA message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1 'B' -> 2 ... 'Z' -...
[LeetCode] Maximum Gap
Maximum GapGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 eleme...
[LeetCode] Candy
Candy There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must hav...
[LeetCode] Longest Common Prefix
Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.解题思路:注意string类的append和push_back方法的使用。1. 先求两个字符串的前缀,在求此前缀与剩下的字符串的前缀。代码如下:class&nbs...
[LeetCode] Divide Two Integers
Divide Two IntegersDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.解题思路:考虑到可能会溢出,因此可用long long类型强制转化int类型。另外,这种类型题目一般都是先确定符号位,将所有的值转化成正数,然...
Restore IP Addresses
Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255....
[LeetCode] Sort Colors
Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will ...
[LeetCode] Fraction to Recurring Decimal
Fraction to Recurring DecimalGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeatin...
樱花树下的家-吉他谱
樱花树下的家——武汉大学校园歌曲词曲:彭挺半个月亮珞珈那面爬上来又是一年三月樱花开一别将是三年还五载明年花开你还来不来我真想这一辈子坐在樱花树下弹着我的破吉他雪白的花瓣贴着脸颊飘落下美丽樱园我的家蓝蓝的天空有朵朝北飞的云彩燕子从南方悄悄把春天捎来绿色的春风吹开了今年的故事你不经意离开摘朵花儿头上戴暖暖的阳光唤你梦中醒来窗外的花才刚刚开多年的日子早已凝结心上象露珠儿花瓣上徘徊熟悉的歌儿在这寂寞的日子...