[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...

[LeetCode] Valid Number

Valid NumberValidate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" =>&...

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)).解题思路:最基本的办...

面试知识点笔记

x=x&(x-1),表示去除x二进制表示的最后一个1位。很容易理解,x-1将最后一个1变成了0,然后与x按位与,新产生的1全变成0面试题:#include <stdio.h> main() {   int b = 3;   int arr[] = {6,&nbs...

[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:[  ...

[LeetCode]Compare Version Numbers

Compare Version NumbersCompare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1,...

[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...

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....