
C++
Eswai
这个作者很懒,什么都没留下…
展开
-
LeetCode: 445. Add Two Numbers II 单链表加法
445. Add Two Numbers IIProblem descriptionYou are given two linked lists representing two non-negative numbers. The most significant digit comes first and each of their nodes contain a single digit. Ad原创 2016-10-30 01:57:41 · 1652 阅读 · 0 评论 -
OpenCV: 矩阵等对象的文件存取方式
OpenCV中的文件存取问题描述在做图像处理等工作时,经常需要对矩阵Mat等各类对象进行存取,那么在OpenCV中有没有合适的方法呢?解决方案OpenCV中保存图片的最常用方式是imwrite(),但是只能将矩阵按8位/24位图片格式保存。如果需要保存浮点数据,要使用FileStorage类,将矩阵保存为XML/YAML文件。示例如下:Mat I;/* Process of Mat I...*/原创 2016-11-02 16:18:30 · 3995 阅读 · 0 评论 -
C++ : 出错解释 base operand of '->' has non-pointer type 'std::pair<int, int>'
C++ ERROR : base operand of ‘->’ has non-pointer type ‘std::pair< int, int>’ 的解释问题描述出错代码(截取部分):list<pair<int,int>> cachelist;unordered_map<int,list<pair<int,int>>::iterator> map;void put(int key, int原创 2017-02-21 22:52:08 · 39861 阅读 · 0 评论 -
LeetCode: 49. Group Anagrams 对颠倒字符串分组
Leetcode: 49. Group Anagrams 对颠倒字符串分组作者: Eswai (eswai@foxmail.com) 优快云: blog.youkuaiyun.com/eswai问题描述Given an array of strings, group anagrams together.Example:, Given: [“eat”, “tea”, “tan”, “ate”, “na原创 2017-02-20 15:51:10 · 473 阅读 · 0 评论 -
Leetcode: 309. Best Time to Buy and Sell Stock with Cooldown 有冷却机制的最优炒股问题
Leetcode: 309. Best Time to Buy and Sell Stock with Cooldown 有冷却机制的炒股问题-作者: Eswai (eswai@foxmail.com) 利用有限状态自动机解决。原创 2017-01-12 19:25:42 · 404 阅读 · 0 评论 -
Leetcode: 18. 4Sum 四数之和
Leetcode: 18. 4Sum 四数之和问题描述Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of targe原创 2017-01-05 16:10:29 · 984 阅读 · 0 评论 -
Leetcode: 15. 3Sum 三数之和
Leetcode: 15. 3Sum 三数之和问题描述Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set m原创 2017-01-05 13:33:28 · 2631 阅读 · 2 评论 -
Leetcode: 441. Arranging Coins
Leetcode: 441. Arranging Coins排列硬币问题描述You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full stair原创 2016-11-28 15:55:01 · 456 阅读 · 0 评论 -
OpenCV: 颜色空间转换 cvtColor()出错?注意浮点数精度
问题描述OpenCV 2.0 中的cvtColor()函数可用于颜色空间的转换,例如RGB转HSV,RGB转YUV等等。这里笔者用它来转灰度图,即RGB2GRAY,出现了错误。/* various operations of Mat I */Mat grayI;cvtColor(I, grayI, COLOR_BGR2GRAY); 解决根据上图控制台的报错提示 OpenCV Error:原创 2016-10-10 11:38:11 · 10515 阅读 · 3 评论 -
OpenCV: 计时方法
OpenCV计时方法问题描述跑一个程序除了看它报不报错,还得计算时间效率对吧。那么在基于C++的OpenCV工程中如何计时呢?解决方案getTickCount函数double t = (double)getTickCount();/*** various operations ***/t = (getTickCount() - t) / getTickFrequency();cout <<原创 2016-10-28 18:47:35 · 1039 阅读 · 0 评论 -
OpenCV: Matrix type矩阵类型宏定义探究
OpenCV:Matrix type矩阵类型宏定义探究老司机可能会知道CV_8UC3=16,CV_32FC3=21,那么这些数字到底是怎么定义的呢?原创 2016-10-16 16:46:56 · 2549 阅读 · 0 评论 -
OpenCV: 图片读取函数imread的文件路径写法
OpenCV:图片读取函数imread的文件路径写法cv::Mat cv::imread( const &string filename, int flags=1)//文件在当前目录下Mat img=imread("test.jpg");//不在当前目录//使用双反斜杠img=imread("folder\\folder2\\test.jpg");img=imread("原创 2016-09-21 11:27:07 · 32101 阅读 · 4 评论 -
OpenCV:批量读取图片
OpenCV:批量读取图片方法1:将图片文件名称改为编号,例如”i.bmp”,其中i=1,2,…,Nchar filename[100];Mat img[N];for(int i=0;i<N;i++){ sprintf(filename,"PATH/%d.bmp",i+1); img[i]=imread(filename); //... other operations原创 2016-09-21 11:28:32 · 1043 阅读 · 0 评论 -
Leetcode: 26. Remove Duplicates from Sorted Array
LeetCode: 26. Remove Duplicates from Sorted Array 删除有序数组中的重复元素问题描述Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate原创 2016-11-03 20:58:42 · 348 阅读 · 0 评论 -
笔试题:2017.9.10爱奇艺校招编程题【平方串】解题思路
问题描述平方串: 形如string s = T + T的字符串目标: 对于字符串s,除去若干字符使其成为平方串,求该平方串的最大长度。思路与实现将s分成两半,求两个子串的最大子序列长度(longest common subsequence)的最大值ans,最长平方串长度就是2*ans。const int MAXN = 50;int c[MAXN][MAXN] = { 0 };// s原创 2017-09-16 02:19:24 · 1398 阅读 · 0 评论