摘要: Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 阅读全文
posted @ 2015-04-14 12:53 Grandyang 阅读(26937) 评论(0) 推荐(1) 编辑
摘要: Given the disparity d and 2D point (x, y) , we can derive the 3D depth using the 4-by-4 reprojection matrix Q as follows:The reprojection matrix Q is ... 阅读全文
posted @ 2015-04-14 06:01 Grandyang 阅读(991) 评论(0) 推荐(0) 编辑
摘要: Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9 阅读全文
posted @ 2015-04-13 12:22 Grandyang 阅读(20872) 评论(5) 推荐(2) 编辑
摘要: Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the dig 阅读全文
posted @ 2015-04-13 07:05 Grandyang 阅读(22092) 评论(4) 推荐(3) 编辑
摘要: Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb 阅读全文
posted @ 2015-04-12 13:19 Grandyang 阅读(20811) 评论(0) 推荐(1) 编辑
摘要: Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen nu 阅读全文
posted @ 2015-04-12 12:03 Grandyang 阅读(38125) 评论(18) 推荐(5) 编辑
摘要: Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found 阅读全文
posted @ 2015-04-09 13:01 Grandyang 阅读(21808) 评论(11) 推荐(3) 编辑
摘要: Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if i 阅读全文
posted @ 2015-04-09 08:31 Grandyang 阅读(14924) 评论(4) 推荐(1) 编辑
摘要: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2015-04-08 15:56 Grandyang 阅读(39403) 评论(5) 推荐(3) 编辑
摘要: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Exampl 阅读全文
posted @ 2015-04-08 14:46 Grandyang 阅读(43499) 评论(8) 推荐(0) 编辑
摘要: Download Git for windowsOpen Git BashType in "ssh-keygen -t rsa", and then press Enter button three timesYou can find the public key in the "file id_r... 阅读全文
posted @ 2015-04-08 03:55 Grandyang 阅读(583) 评论(0) 推荐(0) 编辑
摘要: Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character. 阅读全文
posted @ 2015-04-08 01:39 Grandyang 阅读(30753) 评论(22) 推荐(2) 编辑
摘要: Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses O( 阅读全文
posted @ 2015-04-06 14:59 Grandyang 阅读(29549) 评论(19) 推荐(3) 编辑
摘要: Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You mus 阅读全文
posted @ 2015-04-06 06:53 Grandyang 阅读(26756) 评论(10) 推荐(4) 编辑
摘要: Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文
posted @ 2015-04-04 15:06 Grandyang 阅读(13787) 评论(2) 推荐(1) 编辑
摘要: You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means 阅读全文
posted @ 2015-04-03 11:33 Grandyang 阅读(33078) 评论(7) 推荐(2) 编辑
摘要: Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearrang 阅读全文
posted @ 2015-04-02 06:14 Grandyang 阅读(24379) 评论(11) 推荐(1) 编辑
摘要: SIFT and SURF were moved to nonfree module. You need to add #include header and link with opencv_nonfree library. 阅读全文
posted @ 2015-04-01 23:17 Grandyang 阅读(991) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x, n), which calculates x raised to the power n (i.e., x^n). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: 阅读全文
posted @ 2015-04-01 14:34 Grandyang 阅读(37177) 评论(19) 推荐(1) 编辑
摘要: 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 yo 阅读全文
posted @ 2015-04-01 13:41 Grandyang 阅读(42974) 评论(12) 推荐(2) 编辑
摘要: The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return th 阅读全文
posted @ 2015-03-31 13:54 Grandyang 阅读(10075) 评论(2) 推荐(0) 编辑
摘要: The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return al 阅读全文
posted @ 2015-03-30 13:18 Grandyang 阅读(23468) 评论(3) 推荐(0) 编辑
摘要: Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Ex 阅读全文
posted @ 2015-03-30 09:20 Grandyang 阅读(43214) 评论(11) 推荐(1) 编辑
摘要: You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0]. Each element nums[i] represents the maximum len 阅读全文
posted @ 2015-03-28 03:31 Grandyang 阅读(31542) 评论(4) 推荐(2) 编辑
摘要: You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum ju 阅读全文
posted @ 2015-03-27 13:17 Grandyang 阅读(31356) 评论(15) 推荐(2) 编辑
摘要: Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals 阅读全文
posted @ 2015-03-27 02:53 Grandyang 阅读(37459) 评论(21) 推荐(1) 编辑
摘要: You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval 阅读全文
posted @ 2015-03-26 00:59 Grandyang 阅读(22710) 评论(0) 推荐(0) 编辑
摘要: Initializing "cv::StereoBM bm.state->disp12MaxDiff" should be careful, inappropriate value might crash your program. Suggested that you set it to -1 t... 阅读全文
posted @ 2015-03-25 06:11 Grandyang 阅读(937) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3 Output: [[1,2,3],[8,9, 阅读全文
posted @ 2015-03-24 14:54 Grandyang 阅读(11596) 评论(17) 推荐(0) 编辑
摘要: Given an m x n matrix, return all elements of the matrix in spiral order. Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7, 阅读全文
posted @ 2015-03-24 14:22 Grandyang 阅读(26073) 评论(9) 推荐(1) 编辑
摘要: Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Example 1: Input: nums = [1, 阅读全文
posted @ 2015-03-23 14:57 Grandyang 阅读(30204) 评论(10) 推荐(2) 编辑
摘要: Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2, 阅读全文
posted @ 2015-03-23 08:29 Grandyang 阅读(54284) 评论(1) 推荐(0) 编辑
摘要: 这是Combinations 组合项的延伸,在这里,我们允许不同的顺序出现,那么新的题目要求如下:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4... 阅读全文
posted @ 2015-03-23 07:56 Grandyang 阅读(817) 评论(0) 推荐(0) 编辑
摘要: The set [1, 2, 3, ..., n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following s 阅读全文
posted @ 2015-03-23 01:44 Grandyang 阅读(22053) 评论(6) 推荐(2) 编辑
摘要: Given the head of a linked list, rotate the list to the right by k places. Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] Example 2: 阅读全文
posted @ 2015-03-21 13:49 Grandyang 阅读(14852) 评论(5) 推荐(0) 编辑
摘要: cvSave这个函数是OpenCV中用来保存某个数据类型到文件中常用的函数,它原本共有五个参数,但是在VS2010中只需要填前两个,而在Linux必须填满五个,否则会出错,如下:// VS2010cvSave("m.xml", mat);// LinuxcvSave("m.xml", mat, NU... 阅读全文
posted @ 2015-03-21 07:11 Grandyang 阅读(648) 评论(0) 推荐(0) 编辑
摘要: 如果我们想把OpenCV中的矩阵数据类型cv::Mat保存在一个文件中,可以使用如下的代码:void writeMatToFile(cv::Mat& m, const char* filename) { ofstream fout(filename); if(!fout) { ... 阅读全文
posted @ 2015-03-20 23:33 Grandyang 阅读(5024) 评论(0) 推荐(0) 编辑
摘要: You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to th 阅读全文
posted @ 2015-03-20 15:13 Grandyang 阅读(16072) 评论(7) 推荐(1) 编辑
摘要: There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-rig 阅读全文
posted @ 2015-03-20 14:30 Grandyang 阅读(22828) 评论(7) 推荐(2) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2015-03-20 11:50 Grandyang 阅读(17679) 评论(4) 推荐(3) 编辑
Fork me on GitHub