摘要:
Assume you have an array of length n initialized with all 0's and are given k update operations. Each operation is represented as a triplet: [startInd
阅读全文
posted @ 2016-06-30 08:14
Grandyang
阅读(13521)
推荐(0)
摘要:
Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. You may assume the integer do not conta
阅读全文
posted @ 2016-06-29 12:01
Grandyang
阅读(12113)
推荐(1)
摘要:
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or
阅读全文
posted @ 2016-06-28 22:23
Grandyang
阅读(17915)
推荐(0)
摘要:
Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio
阅读全文
posted @ 2016-06-27 09:53
Grandyang
阅读(15590)
推荐(1)
摘要:
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. Example: Inp
阅读全文
posted @ 2016-06-26 12:40
Grandyang
阅读(17885)
推荐(1)
摘要:
Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example: Input:
阅读全文
posted @ 2016-06-25 12:34
Grandyang
阅读(16455)
推荐(0)
摘要:
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w
阅读全文
posted @ 2016-06-24 23:35
Grandyang
阅读(14626)
推荐(0)
摘要:
在使用OpenCV的三维立体重建的库时,一个重要的步骤就是生成左右视图的差异图Disparity,而控制生成disparity的参数的类是cv::StereoBM,我们有时候需要拷贝一份cv::StereoBM,然后改变其中的参数值,但是如果用默认的等号‘=’来进行拷贝,其实是浅拷贝,如果改变拷贝项
阅读全文
posted @ 2016-06-23 12:07
Grandyang
阅读(1303)
推荐(0)
摘要:
Design a hit counter which counts the number of hits received in the past 5 minutes. Each function accepts a timestamp parameter (in seconds granulari
阅读全文
posted @ 2016-06-22 01:00
Grandyang
阅读(21198)
推荐(1)
摘要:
在使用Qt和OpenCV混合编程时,我们有时需要在两种图片类cv::Mat和QImage之间进行转换,下面的代码参考了网上这个帖子: 还可以用下面的这个代码,参考了这个帖子:
阅读全文
posted @ 2016-06-21 06:46
Grandyang
阅读(4216)
推荐(0)
摘要:
Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value.
阅读全文
posted @ 2016-06-20 13:24
Grandyang
阅读(962)
推荐(0)
摘要:
Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
阅读全文
posted @ 2016-06-19 23:50
Grandyang
阅读(17753)
推荐(0)
摘要:
在使用PCL库的时候,经常需要显示点云,可以用下面这段代码:
阅读全文
posted @ 2016-06-18 12:29
Grandyang
阅读(9274)
推荐(0)
摘要:
Given a sorted array of integers nums and integer values a, band c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in th
阅读全文
posted @ 2016-06-18 06:58
Grandyang
阅读(11954)
推荐(0)
摘要:
Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in t
阅读全文
posted @ 2016-06-17 00:45
Grandyang
阅读(19096)
推荐(0)
摘要:
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th
阅读全文
posted @ 2016-06-16 23:31
Grandyang
阅读(1579)
推荐(0)
摘要:
Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k from each other. All input str
阅读全文
posted @ 2016-06-15 01:01
Grandyang
阅读(16267)
推荐(0)
摘要:
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Given n = 2, return 91. (The answer should be the
阅读全文
posted @ 2016-06-14 04:12
Grandyang
阅读(13721)
推荐(2)
摘要:
Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points. Example 1: Input: [[1,1],[-1,1]] Output:
阅读全文
posted @ 2016-06-13 00:33
Grandyang
阅读(10469)
推荐(0)
摘要:
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the
阅读全文
posted @ 2016-06-12 11:39
Grandyang
阅读(11414)
推荐(0)
摘要:
Design a data structure that supports the following two operations: addWord(word) and search(word)search(word) can search a literal word or a regular
阅读全文
posted @ 2016-06-11 01:19
Grandyang
阅读(1218)
推荐(0)
摘要:
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O''s into 'X''s in that surrounde
阅读全文
posted @ 2016-06-10 00:07
Grandyang
阅读(838)
推荐(0)
摘要:
Given two arrays, write a function to compute their intersection.Notice Each element in the result should appear as many times as it shows in both arr
阅读全文
posted @ 2016-06-09 00:08
Grandyang
阅读(935)
推荐(0)
摘要:
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the w
阅读全文
posted @ 2016-06-08 00:56
Grandyang
阅读(17854)
推荐(1)
摘要:
Given two arrays, write a function to compute their intersection.Notice Each element in the result must be unique. The result can be in any order.Have
阅读全文
posted @ 2016-06-07 00:18
Grandyang
阅读(1156)
推荐(0)
摘要:
Qt可以跟VTK和PCL等其他库联合使用,十分强大,下面的代码展示了如何使用Qt联合PCL库来加载和保存PCL/PLY格式的点云: 通过按钮加载点云: 保存点云: 注意savePCDFileBinary是以二进制的方式来储存,这样保存出来的点云占的硬盘空间较小,但是使用例如notepad++等软件打
阅读全文
posted @ 2016-06-06 09:17
Grandyang
阅读(4940)
推荐(0)
摘要:
Given a binary tree, return all root-to-leaf paths.ExampleGiven the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:[ "1->2->5", "1->3"]
阅读全文
posted @ 2016-06-06 01:26
Grandyang
阅读(1029)
推荐(0)
摘要:
Write an algorithm to determine if a number is happy. A happy number is a number defined by the following process: Starting with any positive integer,
阅读全文
posted @ 2016-06-05 07:21
Grandyang
阅读(2092)
推荐(0)
摘要:
Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. The snak
阅读全文
posted @ 2016-06-04 03:01
Grandyang
阅读(13539)
推荐(0)
摘要:
在Qt中,我们有时候需要把一些参数写入xml文件,方便以后可以读入,类似一种存档读档的操作,例如,我们想生成如下的xml文件: 那么写入的操作请参见如下代码: 读入的操作请参见如下:
阅读全文
posted @ 2016-06-03 00:10
Grandyang
阅读(9603)
推荐(0)
摘要:
Factory is a design pattern in common usage. Please implement a ToyFactory which can generate proper toy based on the given type.ExampleToyFactory tf
阅读全文
posted @ 2016-06-02 00:32
Grandyang
阅读(2512)
推荐(0)
摘要:
Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals. For exampl
阅读全文
posted @ 2016-06-01 04:24
Grandyang
阅读(10746)
推荐(0)
摘要:
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Notice You must
阅读全文
posted @ 2016-05-31 00:07
Grandyang
阅读(841)
推荐(0)
摘要:
在Qt中,我们想要通过对话框来打开某一个图片,可以通过使用QFileDialog来快速实现,参见以下代码: 保存图片可以使用如下代码: 类似内容请参见我之前的博客QDialog, QFileDialog 和 QDesktopServices 的使用方法。
阅读全文
posted @ 2016-05-30 10:36
Grandyang
阅读(1492)
推荐(0)
摘要:
Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock scre
阅读全文
posted @ 2016-05-30 05:40
Grandyang
阅读(18090)
推荐(0)
摘要:
在Qt中,有时候我们想要联合QSpinBox 和 QSlider,使得移动滑块,QSpinBox中的数据会变化,或者我们在QSpinBox中输入一个数值,响应的滑块也会变化,如下图所示: 那么我们可以用如下的代码来实现:
阅读全文
posted @ 2016-05-28 05:58
Grandyang
阅读(2047)
推荐(0)
摘要:
在Qt的界面设计中,我们有时候希望窗口在最大化的时候,上面的控件也跟着缩放,那么我们就需要调整控件的SizePolicy属性,关于这个属性的讲解请参见我之前的博客Qt SizePolicy 属性,由于窗口的拉伸,会导致控件的拉伸,有时候我们只需要某一个或者某几个控件被拉伸,那么我们可以将需要拉伸的控
阅读全文
posted @ 2016-05-27 07:14
Grandyang
阅读(11832)
推荐(0)
摘要:
Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: n
阅读全文
posted @ 2016-05-27 06:21
Grandyang
阅读(18561)
推荐(1)
摘要:
Factory is a design pattern in common usage. Implement a ShapeFactory that can generate correct shape. You can assume that we have only tree different
阅读全文
posted @ 2016-05-20 15:03
Grandyang
阅读(3297)
推荐(0)
摘要:
Implement a simple twitter. Support the following method: postTweet(user_id, tweet_text). Post a tweet.getTimeline(user_id). Get the given user's most
阅读全文
posted @ 2016-05-19 07:41
Grandyang
阅读(2435)
推荐(0)