自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 收藏
  • 关注

原创 Opencv3+VS2017实现交通标志检测

        可靠的交通标志检测是对其进行准确识别的前提,本次作业首先利用交通标志的红色特征域分割出潜在的交通标志区域,然后通过中值滤波、腐蚀、膨胀与填充操作,初步抑制目标图像的噪声,分割出交通标志独立的图像元素,接着针对交通标志具有规则的形状这一关键特征,通过轮廓提取,Harris角点检测方法最终确定出图像中的交通标志区域,实验结果表明了该算法的有效性。        下面是原图与检测后的对比...

2018-05-31 09:43:51 7009 9

原创 【一次过】Lintcode 1119:三个数的最大乘积

给定一个整数数组,找到三个元素,使乘积最大,返回该积。样例样例 1:输入: [1,2,3]输出: 6样例 2:输入: [1,2,3,4]输出: 24注意事项数组的长度范围为[3, 10^4],所有的元素范围为[-1000, 1000]。 任意三个元素的积不会超过32位有符号整数的范围。解题思路: 直接先排序,后找相乘最大。注意这里要考虑负...

2018-05-29 11:29:24 184

原创 【两次过】Lintcode 1209:构造矩形

对于一个Web开发者,如何设计页面大小很重要。所以,给定一个矩形大小,设计其长(L)宽(W),使其满足如下要求:1. 矩形区域大小需要和给定目标相等。2. 宽度W不大于长度L,也即L >= W.3. 长和宽的差异尽可能的小。返回设计好的长度L和宽度W。样例样例:输入: 4输出: [2, 2]解释: 目标区域是4, 所有可能的构造方法是[1,4]...

2018-05-29 11:03:28 218

原创 【一次过】Lintcode 12 :带最小值操作的栈

实现一个栈, 支持以下操作:push(val)将 val 压入栈 pop()将栈顶元素弹出, 并返回这个弹出的元素 min()返回栈中元素的最小值要求 O(1) 开销.样例样例 2:输入: push(1) min() push(2) min() push(3) min()输出: 1 1 1注意事项保证栈中没有数...

2018-05-28 13:49:19 270

原创 【一次过】Lintcode 11:二叉查找树中搜索区间

给定两个值 k1 和 k2(k1 < k2)和一个二叉查找树的根节点。找到树中所有值在 k1 到 k2 范围内的节点。即打印所有x (k1 <= x <= k2) 其中 x 是二叉查找树的中的节点值。返回所有升序的节点值。样例如果有 k1 =10和 k2 =22, 你的程序应该返回[12, 20, 22]. 20 / \ 8 22 /...

2018-05-28 13:20:28 153

原创 【一次过】Lintcode 3. 统计数字

计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例例如n=12,k=1,在[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],我们发现1出现了5次(1, 10, 11, 12)解题思路: 思路很清晰,遍历然后对每个数字分解统计数目即可。 需要额外注意的是0的特殊情况,具体代码中有。class Solution {...

2018-05-26 13:47:44 145

原创 【一次过】Lintcode 102: 带环链表

给定一个链表,判断它是否有环。样例```样例 1: 输入: 21->10->4->5, then tail connects to node index 1(value 10). 输出: true 样例 2: 输入: 21->10->4->5->null 输出: false```挑战不要使用额外的空间解题思...

2018-05-26 13:26:45 268

原创 【一次过】【bitset的使用】Lintcode 987:Binary Number with Alternating Bits

Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.ExampleExample 1:Input: 5Output: TrueExplanation:The binary represent...

2018-05-21 22:07:27 114

原创 【两次过】Lintcode 983: Baseball Game

You're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round's score): Directly represents the number of points you get in this...

2018-05-21 21:46:14 147

原创 【两次过】Lintcode 1172:二叉树倾斜程度

给定一个二叉树,返回整棵树的倾斜程度。一个节点的倾斜程度定义:左子树的所有节点和,与右子树所有节点和的绝对值差。空节点的倾斜程度定义为0。整棵树的倾斜程度定义:所有节点的倾斜程度之和。样例样例 1:输入: {1,2,3}输出: 1解释: 1 / \ 2 3节点2的倾斜程度 : 0节点3的倾斜程度 : ...

2018-05-20 21:01:13 322

原创 【二次过】Lintcode 1138:Can Place Flowers

Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.Given ...

2018-05-20 20:25:53 164

原创 【简单】Lintcode 372:Delete Node in a Linked List

 Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.ExampleLinked list is 1-&gt;2-&gt;3-&gt;4, and given node 3, delete the node in pla...

2018-05-18 22:33:28 203

原创 二分搜索树C++模板实现

    二分搜索树最难的操作是remove,floor,ceil,需要多看。BST.h#pragma once#include&lt;iostream&gt;#include&lt;queue&gt;#include&lt;cassert&gt;using namespace std;template&lt;typename Key, typename Value&gt;class ...

2018-05-18 22:14:31 347

原创 【多次过】Lintcode 888:Valid Word Square

Given a sequence of words, check whether it forms a valid word square.A sequence of words forms a valid word square if the k^th row and column read the exact same string, where 0 ≤ k &lt; max(numRows,...

2018-05-17 17:33:57 146

原创 【简单】Lintcode 1385:Lucky Number Eight

8 is the lucky number of Xiaojiu. Xiaojiu wants to know how many numbers in the numbers 1~n contain 8. Notice1 &lt;= n &lt;= 1000000ExampleGiven n = 20, return 2.Explanation:Only 8,18 contains 8.Giv...

2018-05-17 16:44:27 379

原创 【简单】Lintcode 85:在二叉查找树中插入节点

给定一棵二叉查找树和一个新的树节点,将节点插入到树中。你需要保证该树仍然是一棵二叉查找树。样例给出如下一棵二叉查找树,在插入节点6之后这棵二叉查找树可以是这样的: 2 2 / \ / \1 4 --> 1 4 / / \ 3 3 6挑战...

2018-05-14 22:30:49 168

原创 【简单】Lintcode 97:二叉树的最大深度

 Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.ExampleGiven a binary tree as fol...

2018-05-13 21:24:29 157

原创 【两次过】Lintcode 69:二叉树的层次遍历

给出一棵二叉树,返回其节点值的层次遍历(逐层从左往右访问)样例给一棵二叉树{3,9,20,#,#,15,7}: 3 / \9 20 / \ 15 7返回他的分层遍历结果:[ [3], [9,20], [15,7]]挑战挑战1:只使用一个队列去实现它挑战2:用DFS算法来做解题思路: 利用一个队列来辅助层级遍...

2018-05-13 09:56:53 186

原创 【简单】Lintcode 68:Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes' values.Have you met this question in a real interview? YesExampleGiven binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2...

2018-05-12 17:09:09 122

原创 【简单】Lintcode 67:Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values.Have you met this question in a real interview? YesExampleGiven binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2...

2018-05-12 17:04:51 123

原创 数据结构-链表二叉树-【C++模板实现】

    此树根节点索引为0,不存储数据节点,从根节点开始向下的节点开始存储数据,也就是从节点1开始存储数据。Node.h#pragma once#include&lt;iostream&gt;using namespace std;template&lt;class T&gt;class Node{public: int index; T data; Node&lt;T&g...

2018-05-12 11:29:07 692

原创 【简单】Lintcode 133:Longest Word

Given a dictionary, find all of the longest words in the dictionary.ExampleGiven{ "dog", "google", "facebook", "internationalization", "blabla"}the longest words are(is) ["internationaliza.

2018-05-11 22:24:07 289

原创 数据结构-数组二叉树-【C++实现】

    本二叉树是索引0开始为头数据节点,则*2+1为其左孩子,*2+2为右孩子。数组中元素值为0该节点为空。代表亲测可运行。Tree.h#pragma onceclass Tree{public: Tree(const int &amp;pRoot,int size);//传递初始头数据节点的值与容量 ~Tree(); int SearchNode(int nodeIndex);...

2018-05-10 16:45:34 151

原创 【简单】Lintcode 101:删除排序数组中的重复数字 II

Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should return length =5, and A is now[1,1,2,2,3].解题思路: ...

2018-05-10 11:25:24 139

原创 【简单】Lintcode 100: 删除排序数组中的重复数字

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with con...

2018-05-10 11:15:49 117

原创 PAT(乙级)-1016-部分A+B

正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA。例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6。现给定A、DA、B、DB,请编写程序计算PA + PB。输入格式:输入在一行中依次给出A、DA、B、DB,中间以空格分隔,其中0 &lt; A, B &lt; 1010。输出格式:在一行中输出PA + PB的值。输入样例1:3862...

2018-05-09 10:01:16 141

原创 【简单】Lintcode 167:链表求和

You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored inreverseorder, such that the 1's digit is at the head of the list. Write a function...

2018-05-07 23:05:55 141

原创 2018大华软件校园创新挑战赛-解码数据

题目:在H.264视频编码标准中,编码帧由NALU头和NALU主体组成,其中NALU头由一个字节组成。在实际编码时,在每个NAL前添加起始码 0x000001,解码器在码流中检测到起始码,当前NAL结束。为了防止NAL内部出现0x000001的数据,在编码完一个NAL时,如果检测出有连续两个0x00字节,就在后面插入一个0x03。当解码器在NAL内部检测到0x000003的数据,就把0x03抛弃,...

2018-05-06 13:57:55 132

原创 2018大华软件校园创新挑战赛-神奇的数字

题目:一个数可以用二进制表示,也可以用十进制表示,如果该数的二进制表示法所有位数字之和等于十进制表示法所有位数字之和,则称该数为神奇数。比如:21(十进制)=10101(二进制),所有位数之和为2+1=3,1+0+1+0+1=3。求小于等于M的神奇数有多少个。输入:输入的第一行指定用例数量T;用例的第一行输入数字M;输出:输出神奇数字的个数例子:Input:2100300Output:311解题思...

2018-05-06 13:45:58 255

原创 2018大华软件校园创新挑战赛-翻转指定元素链表

题目:给定一个链表,实现一个函数,将链表中每k个节点进行翻转,若最后一组节点数量不足k个,则按实际个数翻转。例如:给定链表1-&gt;2-&gt;3-&gt;4-&gt;5-&gt;6-&gt;7-&gt;8-&gt;NULL,k=3,翻转后输出3-&gt;2-&gt;1-&gt;6-&gt;5-&gt;4-&gt;8-&gt;7-&gt;NULL。翻转函数reverse有两个参数

2018-05-06 13:36:27 142

原创 PAT(乙级)-1013-数素数

令Pi表示第i个素数。现任给两个正整数M &lt;= N &lt;= 104,请输出PM到PN的所有素数。输入格式:输入在一行中给出M和N,其间以空格分隔。输出格式:输出从PM到PN的所有素数,每10个数字占1行,其间以空格分隔,但行末不得有多余空格。输入样例:5 27输出样例:11 13 17 19 23 29 31 37 41 4347 53 59 61 67 71 73 79 83 89...

2018-05-06 11:40:24 151

原创 PAT(乙级)-1012-数字分类

给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字:A1 = 能被5整除的数字中所有偶数的和;A2 = 将被5除后余1的数字按给出顺序进行交错求和,即计算n1-n2+n3-n4...;A3 = 被5除后余2的数字的个数;A4 = 被5除后余3的数字的平均数,精确到小数点后1位;A5 = 被5除后余4的数字中最大数字。输入格式:每个输入包含1个测试用例。每个测试用例先给出一个不超过1000...

2018-05-04 16:26:54 130

原创 PAT(乙级)-1011-A+B和C

给定区间[-231, 231]内的3个整数A、B和C,请判断A+B是否大于C。输入格式:输入第1行给出正整数T(&lt;=10),是测试用例的个数。随后给出T组测试用例,每组占一行,顺序给出A、B和C。整数间以空格分隔。输出格式:对每组测试用例,在一行中输出“Case #X: true”如果A+B&gt;C,否则输出“Case #X: false”,其中X是测试用例的编号(从1开始)。输入样例:4...

2018-05-04 10:05:15 86

原创 【简单】Lintcode 166: Nth to Last Node in List

Find the nth to last element of a singly linked list. The minimum number of nodes in list is n.ExampleGiven a List  3-&gt;2-&gt;1-&gt;5-&gt;null and n = 2, return node  whose value is 1.解题思路:    采用双指针...

2018-05-03 17:49:41 145

原创 【一次过】Lintcode 112:删除排序链表中的重复元素

给定一个排序链表,删除所有重复的元素每个元素只留下一个。样例给出 1-&gt;1-&gt;2-&gt;null,返回 1-&gt;2-&gt;null给出 1-&gt;1-&gt;2-&gt;3-&gt;3-&gt;null,返回 1-&gt;2-&gt;3-&gt;null解题思路:    非常简单,用一个指针currentNode与他的下一个元素两者的值进行比较,若相同则删...

2018-05-03 17:22:29 141

原创 2018年大华软件创新挑战赛-模拟题3-魔法数字

题目:有一种特殊的正整数(int类型),将数分为两侧,每侧至少有一位数,两侧的每个数字相加相等,请写出判断的方法用来检测是否这种数。比如:1236,可以拆分为123和6。输入:输入的第一行指定用例数量T;用例的第二行输入正整数;输出:输出是否为特殊的正整数例如:intput:212321454543622output:11--------------------------------------...

2018-05-03 16:55:07 143

原创 【简单】Lintcode 165:Merge Two Sorted Lists

 Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order.Have...

2018-05-01 19:44:52 156

原创 【一次过】Lintcode 96: 链表划分

给定一个单链表和数值x,划分链表使得所有小于x的节点排在大于等于x的节点之前。你应该保留两部分内链表节点原有的相对顺序。 样例给定链表 1-&gt;4-&gt;3-&gt;2-&gt;5-&gt;2-&gt;null,并且 x=3返回 1-&gt;2-&gt;2-&gt;4-&gt;3-&gt;5-&gt;null.解题思路1:    可将整个链表先分离为两个小的链...

2018-05-01 17:33:23 181

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除