摘要:
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.I wrote that function be... 阅读全文
摘要:
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Do not think to... 阅读全文
摘要:
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-... 阅读全文
摘要:
Recording my thought on the go might be fun when I check back later, so this kinda blog has no intention to be read by others(its just for recording, ... 阅读全文
摘要:
经过一段时间的搜索,决定把搜过的资料都汇集在此,以免重复劳动,几乎来自stackoverflowOpenCV C++/Obj-C: Detecting a sheet of paper / Square DetectionFind corner of papersHow to remove convexity defects in a Sudoku square?以上是纸张检测的问题。http://en.wikipedia.org/wiki/3D_projectionwikiPedia关于3D投影,透视变换的条目,可以有一个基本了解。Executing cv::warpPerspective 阅读全文
摘要:
follow this instruction:http://blog.csdn.net/liushuaikobe/article/details/8729652and if you encounter some complie error like below when you try to install PIL/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/tk.h:78:11: fatal error: ... 阅读全文
摘要:
n(n+1)/2是一个数列的元素两两运算后的不重复结果数。如图:假如数列a = 1,2,3....n。那么该数列内的元素两两相乘,则会构建出上图中的表格,这个表格应该有n x n 个元素。用程序写出来大概就是这样:for (int i=0; i 2r = n(n-1) => r = n(n-1)/2得到了重复数r,那么剩下多少不重复的呢? n*n - r = n(n+1)/2 wala~ QED----Note---这其实是一个可重复的N choose M 组合问题,而这里的M是2,有时间的话想好好证明一下这个问题 阅读全文
摘要:
pongo上的一道题,刚好闲下来可以练练手。题目: 给定一个包含1-n的数列,我们通过交换任意两个元素给数列重新排序。求最少需要多少次交换,能把数组排成按1-n递增的顺序,其中,数组长度不超过100。 例如: 原数组是3,2,1, 我们只需要交换1和3就行了,交换次数为1,所以输出1。 原数组是2,3,1,我们需要交换2和1,变成1,3,2,再交换3和2,变为1,2,3,总共需要的交换次数为2,所以输出2。 1 int getMinPos(int *a,int start, int end){ 2 int min = start; 3 for (int i=start; i a... 阅读全文