自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(110)
  • 资源 (8)
  • 收藏
  • 关注

原创 Contains Duplicate II

Given an array of integers and an integer k, return true if and only if there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most

2015-11-29 22:39:00 293

转载 关联容器

关联容器的类型: map:关联数组;元素通过键来从存储读取set:大小可变的集合,至此后通过建实现快速读取multimap:支持同一个键多次出现的map类型multiset:支持同一个键多次出现的set类型一般来说,如果希望有效地存储不同值的集合,那么使用set比较合适,而map容器则更适用于需要存储乃至修改每个键所干练的值的情况。在做某种文本处理时,可

2015-11-29 22:28:30 289

转载 顺序容器

容器类共享公共的接口,这使标准库更容易学习,只要学会其中一种类型就能运用令一种类型,每种容器类型提供一种不同的时间和功能折中方案,通常不需要修改代码,只需改变类型声明,用一种容器类型代替另一容器类型就可以优化程序的性能。  容器容纳特定类型对象的集合,它将单一类型元素聚集起来成为容器。然后根据位置来存储和访问这些元素,这就是顺序容器。  标准库定义 了三种顺序容器类型vec

2015-11-29 22:25:43 243

转载 string实现

#includeusing namespace std; class String{ friend ostream& operator<< (ostream&,String&);public: String(const char* str=NULL); //赋值构造兼默认构造函数(char) String(const String &o

2015-11-29 22:24:54 243

转载 hash表

hash表,有时候也被称为散列表。个人认为,hash表是介于链表和二叉树之间的一种中间结构。链表使用十分方便,但是数据查找十分麻烦;二叉树中的数据严格有序,但是这是以多一个指针作为代价的结果。hash表既满足了数据的查找方便,同时不占用太多的内容空间,使用也十分方便。    打个比方来说,所有的数据就好像许许多多的书本。如果这些书本是一本一本堆起来的,就好像链表或者线性表一样,整个数据会显

2015-11-29 22:21:31 240

转载 set中常用的方法

set中常用的方法begin()        ,返回set容器的第一个元素end()      ,返回set容器的最后一个元素clear()          ,删除set容器中的所有的元素empty()    ,判断set容器是否为空max_size()   ,返回set容器可能包含的元素最大个数size()      ,返回当前set容器中

2015-11-29 22:19:01 2135

转载 set和multiset容器

1 set和multiset容器的能力set 和multiset容器的内部结构通常由平衡二叉树(balancedbinary tree)来实现。当元素放入容器中时,会按照一定的排序法则自动排序,默认是按照less2 set和multiset容器的操作Constructor and Destructor[cpp] view plaincopy

2015-11-29 22:18:23 275

转载 map的详细用法

[cpp] view plaincopymap的详细用法:        map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。这里说下map内部数据的组织,map内部自建一颗红黑树(一种非

2015-11-29 22:14:03 460

原创 Contains Duplicate

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element

2015-11-29 22:12:22 238

原创 Power of Two

Given an integer, write a function to determine if it is a power of two.判断一个数是否是2的幂,判断方法主要依据2的N次幂的特点:仅有首位为1,其余各位都为0.方法1: n & n-1 == 0?123456

2015-11-29 21:51:01 304

原创 n&(n-1)的妙用

n&(n-1)作用:将n的二进制表示中的最低位为1的改为0,先看一个简单的例子:n = 10100(二进制),则(n-1) = 10011 ==》n&(n-1) = 10000可以看到原本最低位为1的那位变为0。弄明白了n&(n-1)的作用,那它有哪些应用?1. 求某一个数的二进制表示中1的个数while (n >0 ) {      count ++;      n

2015-11-29 21:43:42 321

转载 判断二进制数1的个数

写一函数int count(char c)返回字符c的二进制数所含1的个数,例如c=3,其二进制数为00000011,那么此函数返回2int count(char a){ int sum=0; char a=6; int i; for(i=7;i>=0;i--) { sum+=((a>>i)&0x01); } return sum;}

2015-11-29 21:37:49 597

转载 合并a[0..mid]和a[mid+1,n-1],其中这两个数组分别有序

使用两个指针i和j分别指向两段数组的开头,如果a[i]a[j-1]向后平移一个位置,然后将tmp赋值到i这个位置void merge(int a[],int mid,int n){ int i,j; i=0,j=mid; while(i<n&&j<n&&i<j){ if(a[i]<a[j]) i++; else{ int tmp=a[j]

2015-11-29 16:40:16 797

原创 Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a

2015-11-29 16:30:33 248

原创 Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2015-11-29 15:55:12 255

转载 链表反转的几种形式

// From curr reverse to end, return reversed linked list head.ListNode *unguarded_reverse(ListNode *prev, ListNode *curr, ListNode *end){ ListNode *next = NULL; while (curr != end)

2015-11-28 17:50:18 335

转载 整数转化成字符串; 字符串转换为整数

整数转化成字符串; 字符串转换为整数/*整数转化成字符串*/char *IntToStr(int num, char str[]){ int i = 0, j = 0; char temp[100]; while(num) { temp[i] = num % 10 + '0'; //取模运算得到从后往前的每一个数字变成字符 num = num / 10; i++; }

2015-11-28 17:47:55 299

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:1、两个输入时字符串,要变成数字,最后返回字符串。2、进位的问题,相加的时候,是否产生进位,进位标志表示,进位则是1,否则为0,怎

2015-11-28 17:42:01 351

原创 Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille

2015-11-28 15:29:19 246

原创 输出之字形结构

void printZigzag(const string &s, int nRows) { if(s.empty() || nRows < 1) return; if (nRows == 1) { cout<<s<<endl; return; } int zigSpan = nRows

2015-11-28 15:01:55 333

原创 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I

2015-11-28 14:56:00 259

原创 Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string

2015-11-27 21:47:32 196

原创 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2015-11-27 20:32:17 240

原创 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 target.Note:Element

2015-11-27 17:03:52 190

转载 十三种基于直方图的图像全局二值化算法原理、实现、代码及效果。

图像二值化的目的是最大限度的将图象中感兴趣的部分保留下来,在很多情况下,也是进行图像分析、特征提取与模式识别之前的必要的图像预处理过程。这个看似简单的问题,在过去的四十年里受到国内外学者的广泛关注,产生了数以百计的阈值选取方法,但如同其他图像分割算法一样,没有一个现有方法对各种各样的图像都能得到令人满意的结果。     在这些庞大的分类方法中,基于直方图的全局二值算法占有了绝对的市场份额,

2015-11-27 10:41:50 906

原创 图像去噪

噪声主要可以分为脉冲噪声和高斯噪声,我们在现实中看到的图像一般都会含有噪声,在对图像做后续处理时,要对图像进行去噪处理,这样也被称作图像滤波,图像滤波可分为空间域滤波、频率域滤波两大类。1空间域滤波降噪空间域滤波降噪的基本原理是指直接对图像所在的二维空间进行处理,也就是直接对每一像素点的灰度值进行处理,针对这一特点,空间域去噪通常用中值滤波法、邻域滤波法以及自适应滤波法

2015-11-27 10:28:32 4647

原创 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact

2015-11-27 09:41:34 260

转载 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:Elements in a triplet (a,b

2015-11-27 09:11:44 259

原创 Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2015-11-26 23:04:15 263

原创 1、Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2015-11-26 22:39:17 245

转载 Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive

Range Sum Query - ImmutableTotal Accepted: 696 Total Submissions: 2406 Difficulty: EasyGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j)

2015-11-26 22:11:50 921

原创 Set Matrix Zeroes

Set Matrix ZeroesGiven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.思路:如果允许额外存储行和列清零的信息,那么题目就没有意思了。希望只用O(1)的存储空间的时候,我们就得利用矩阵本身的存储空间了:把清零的信息保存在第一

2015-11-26 21:00:07 317

原创 生成一个螺旋数组

Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[[ 1, 2, 3 ],[ 8, 9, 4 ],

2015-11-26 20:40:04 367

原创 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or

1. Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ]

2015-11-26 20:23:21 1134

原创 matlab矩阵分解

矩阵分解是指根据一定的原理用某种算法将一个矩阵分解成若干个矩阵的乘积。常见的矩阵分解有LU分解(三角分解)、QR分解(正交变换)、Cholesky分解,以及Schur分解、Hessenberg分解、奇异分解等。 (1) LU分解(三角分解)矩阵的LU分解就是将一个矩阵表示为一个交换下三角矩阵和一个上三角矩阵的乘积形式。线性代数中已经证明,只要方阵A是非奇异(即行列式不等于0

2015-11-26 16:27:25 1030

转载 矩阵求导公式

今天推导公式,发现居然有对矩阵的求导,狂汗--完全不会。不过还好网上有人总结了。吼吼,赶紧搬过来收藏备份。基本公式:Y = A * X --> DY/DX = A'Y = X * A --> DY/DX = AY = A' * X * B --> DY/DX = A * B'Y = A' * X' * B --> DY/DX = B * A'1. 矩阵Y对标量x

2015-11-26 16:24:14 2617

原创 matlab中矩阵的左除右除

左除右除是矩阵除法的两种形式。 由于矩阵的特殊性,A*B通常不等于B*A,除法也一样。所以要区分左右。右除式A/B,相当于A*inv(B)对于,左除式A\B,则相当于inv(A)*B意思就是A右除B,相当于A右乘B的逆矩阵,A左除B,相当于A的逆矩阵左乘B

2015-11-26 16:21:18 8847

转载 从尾到头打印链表

从尾到头打印链表 题目:输入一个链表的头结点,从尾到头反过来打印出每个结点的值。链表结点定义如下:struct ListNode{ int m_nKey; ListNode *m_pNext;};解决这个问题肯定要遍历链表。遍历的顺序是从头到尾的顺序,可输出的顺序却是从尾到头。也就是说第一个遍历到的结点最后一个输出,而最后一个遍历到得结

2015-11-25 18:55:29 413

原创 交叉验证

交叉验证(Cross-Validation)的基本思想:将原数据进行分组,一部分做为训练集,另一部分做为验证集,首先用训练集对不同参数的模型进行训练,再利用验证集来测试训练得到的模型,进而用验证集的测试误差来衡量模型中的参数。常用的交叉验证的方法:( 1)Hold-out 方法       Hold-out 方法即将原数据随机的分成两组,一组用作训练数据集,另一组用

2015-11-25 14:31:36 3108

原创 拉格朗日对偶性和似然函数

在学习最大熵模型和SVM的过程中,我们看到,前者需要求解满足所有已知条件并且使得熵最大的模型,后者需要求解满足间隔一致性约束条件并且使得几何间隔最大的超平面,归结起来其求解问题都是带约束的极值问题,其解决方法一般采用拉格朗日对偶原理,对于概率性问题也可以用极大似然法来求解。下面简单介绍拉格朗日对偶原理和似然函数。拉格朗日对偶原理:约束条件可以分成不等式约束条件和等式约束条件,只有等

2015-11-25 09:40:41 926

随机一致采样算法C++ 代码

随机一致采样算法C++ 代码,用于随机一直采样的详细过程

2015-09-07

径向对称变换

径向对称变换,用于检测人眼的瞳孔区域的中心,亮暗两种区域的检测对称的性质

2015-09-07

ASM 模型对人脸的特征点的检测

ASM 模型对人脸的特征点的检测,可以检测出人脸特征点,可以进行视频的中特征点的处理,,,表情识别啥的,,还可以添加上去三角剖分

2015-09-07

随机一致抽样例子代码详解

随机一致抽样例子代码详解,很好的理解随机一致抽样的过程,结合原理

2015-09-06

径向基函数插值的代码

径向基函数插值的代码,用于一维 二维三维数据的插值

2015-09-05

高斯回归过程代码

高斯回归过程代码,用于得到自变量和因变量之间的关系

2015-07-22

图像多分辨率金字塔代码

图像多分辨率金字塔代码,对图像进行高斯滤波,然后进行上下采样, 得到图像的多分辨率金字塔

2015-07-16

模式识别的几种方法

主要讲述几种模式识别的方法在实际中的不同运用

2014-07-24

空空如也

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

TA关注的人

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