自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

吞天噬神

春风十里不如掰弯你

  • 博客(37)
  • 收藏
  • 关注

原创 manacher算法注意事项

manacher算法注意事项manacher算法用来求解一个字符串中的最长回文子串,类似12421,回文最大长度为5./**第一步:将字符串改写为奇数个数,简化问题,不用考虑偶数的情况,坑点:必须额外添加的字符出现在首位,如:#1#2#4#2#1#,如果写成1#2#4#2#1,最后结果会出现问题。*第二步:对处理后的字符串求回文长度。对每一个i>=0&&i<len的字符,以该字符为轴求取回文长度

2017-03-30 15:49:05 258

原创 二分查找法

二分查找法注意事项midFind(int a[], int s, int e, int data);1. 分为递归和非递归,但应尽量避免递归。 2. 非递归中终止条件分为while ( s < e )和while ( s <= e ) ` //终止条件while(s < e);参数e = v.size() bool midFind(vector<int>& v ,

2017-03-30 11:30:19 205

原创 leetcode- Symmetric Tree

Question:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3

2017-03-27 22:05:29 247

原创 leetcode- Sum of Left Leaves

Question:Find the sum of all left leaves in a given binary tree.Example:3/ \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.Sol

2017-03-16 22:32:57 221

原创 leetcode-Minimum Moves to Equal Array Elements

Question:Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Input: [1,2,3]O

2017-03-15 23:19:31 179

原创 leetcode-Minimum Absolute Difference in BST

Question: Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input:1 \ 3 / 2Output: 1Explanation:

2017-03-14 23:35:38 185

原创 leetcode-Happy Number

Question: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, replace the number by the sum of the squ

2017-03-07 17:47:04 273

原创 leetcode-Ugly Number

Question:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly si

2017-03-07 17:46:07 264

原创 leetcode-Basic Calculator

Question:Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and em

2017-03-05 11:04:04 232

原创 leetcode-Find K Pairs with Smallest Sums

Question:You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u,v) which consists of one element from the first array and one element from the seco

2017-03-03 17:18:59 206

原创 leetcode-Evaluate Reverse Polish Notation

Question:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples:[“2”, “1”, “+”, “3”

2017-03-02 17:56:22 162

原创 leetcode-Sort Characters By Frequency(基数排序实现)

Question:Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input: “tree”Output: “eert”Explanation: ‘e’ appears twice while ‘r’ and ‘t’ both appear once. So

2017-02-28 17:48:45 315

原创 leetcode-Next Greater Element II

Question: Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is th

2017-02-27 21:30:41 223

原创 leetcode-Merge Two Sorted Lists

Question: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Subscribe to see which companies asked this quest

2017-02-26 22:59:56 185

原创 leetcode-Decode Ways

Question:A message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26Given an encoded message containing digits, determine the t

2017-02-25 23:20:16 181

原创 leetcode-Generate Parentheses

Question:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ “((()))”, “(()())”, “(())()”, “

2017-02-23 18:58:30 177

原创 leetcode-Remove Nth Node From End of List

Question:Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linke

2017-02-22 18:04:40 158

原创 leetcode- Letter Combinations of a Phone Number

Question: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st

2017-02-19 15:29:31 179

原创 leetcode-3Sum clostest

Question: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

2017-02-15 18:09:23 212

原创 leetcode-3sum(n^2)

Question: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 must not conta

2017-02-15 18:07:42 211

原创 leetcode-3sum(N^2logN)

题目: 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 must not contain d

2017-02-10 18:17:25 238

原创 二分查找法注意事项

二分查找法注意事项midFind(int a[], int s, int e, int data);1. 分为递归和非递归,但应尽量避免递归。 2. 非递归中终止条件分为while ( s < e )和while ( s <= e ) ` //终止条件while(s < e);参数e = v.size() bool midFind(vector<int>& v ,

2017-02-10 18:14:13 197

原创 leetcode-Valid Parenthese

括号匹配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 valid b

2017-02-08 18:52:11 211

原创 leetcode-Hamming Distance

汉明码距离The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note: 0 ≤ x, y < 231.

2017-02-07 19:07:02 149

原创 北邮研究生2016年算法期末考试试题

计算递归方程:两路归并排序 ,说明其算法原理,并用c语言实现,计算最坏情况下复杂度。图的最短路径 ,图G=< V,E >,说明使用的数据结构,并描述从起始点到其他点的最短路径的算法。 分治法:描述快速傅里叶变换算法,并计算其时间复杂度。DP:使用动态规划设计01背包算法,物品个数n,容量V,物品体积分别为:v[0],v[1],…,v[n-1];价值为c[0],c[1],…,c[n-1],设计

2016-06-28 16:33:43 2802

原创 欧几里得算法相关

欧几里得算法定理:两个整数的最大公约数等于其中较小的那个数和两数的相除余数的最大公约数。最大公约数(greatest common divisor)缩写为gcd。证明: a / b = k …… r 即证明gcd(a,b) = gcd (b ,r)。 1. 令 c = gcd( a ,b) ,则a = mc; b = nc ;m , n 互素,否则 c 就不是最大公约数。m,n 为整数。

2016-01-24 19:47:38 936

原创 密码学(2)-古典密码学

古典密码学虽然现在已经不再使用,但其反映了密码设计和破译的基本思想,是学习密码学的入口。 古典密码学主要有两种体制:置换密码和代换密码。置换密码根据一定的规则重新排列明文,以便打破原有的结构特性。即改变字符的原始位置,但字符还是那些字符。列置换:比如明文m = “Beijing 2008 Olympic Games”, 密钥=(1 4 3)(5 6)。该密钥表示:一个括号一个循环,f(1)

2016-01-24 18:23:31 1217

原创 密码学概论(1)

为什么要学习密码学?答:信息安全是密码学的目标,密码学是保障信息安全的核心技术,但不是唯一的手段。信息安全的目标和攻击手段对应关系?机密性———-截取(被动攻击,其他都是主动攻击) 完整性———-篡改 认证性———-伪造 可用性———-中断 不可否认性–/–重放(重放的攻击手段并不是破坏不可否认性的手段)密码学发展史?传统密码 1.1 古典密码学(~19世纪末):凯撒密码 1.2

2016-01-24 16:30:50 800

原创 我看Java虚拟机(8)---高效并发

内存模型和线程由于处理器的速度与存储和通讯子系统之间的速度相差太大,所以出现了并发和缓存等技术,来减弱这种差距。 本节简要介绍Java内存模型,volatile变量。Java内存模型每个线程都会保持一个工作内存,线程对于变量的操作,都在工作内存中进行,操作完成之后,再刷新至主内存。其模型如下:内存操作:lock(锁定)unlock(解锁)read(读取)load(载入)use(使用)a

2015-12-20 16:54:10 472

原创 我看Java虚拟机(7)---解释器和JIT编译器

Java是被定为为解释性语言,JIT编译器并不是强制需要的,也并非所有的虚拟机都是用解释器+编译器的并存架构。但主流的商用虚拟机如Hotspot、J9等都采用这种并存的架构。解释器和编译器比较解释器优点:省去编译时间,启动速度快 编译器优点:对代码进行优化,执行效率高 两种方式的优点各为对方的缺点。即解释器的缺点是执行效率低下,编译器的缺点是启动速度慢。很容易理解。Java虚拟机由于Java虚拟

2015-12-20 14:09:04 2320

原创 我看Java虚拟机(6)---虚拟机字节码执行

栈帧是虚拟机栈中的栈元素,栈帧存储方法的局部变量表,操作数栈,动态链接和方法返回地址信息,附加信息。局部变量表:局部变量表单位成为变量槽(Slot),一个Slot存储32位以内的数据类型,对于long和double,64位,可分为两个Slot存储,由于虚拟机栈是线程独有的,所以这么存储是安全的。 Slot是复用的,当某一Slot数据超出作用范围,它就可以被复用。 对于实例方法,局部变量表索引为0

2015-11-29 22:08:59 301

原创 我看Java虚拟机(5)---虚拟机加载机制

经过上节的讲解,我们已经知道了Java代码——》字节码的过程,产生了字节码,下一步就是将字节码读入虚拟机,虚拟机将该部分分为七个步骤: 加载->验证->准备->解析->初始化->使用->卸载 我们主要研究前5步。加载读入二进制字节流,并不限定是class文件,可以是zip,jar,网络获取或者其他。将字节流代表的静态结构转换为方法区的运行时数据结构在堆中创建代表这个类的java.lang.

2015-11-29 21:50:17 388

原创 我看Java虚拟机(4)---Javac编译器

编译过程分为三个部分:解析与填充符号表插入式注解处理器的注解处理过程分析和字节码的生成解析与填充符号表词法语法分析,生成抽象语法树(AST,Abstract Syntax Tree); 填充符号表注解处理器该部分可以操作上一步生成的语法树,修改一次,解析和填充符号表重新做一次,直到注解处理器再没有对语法树进行修改为止。 《深入理解Java虚拟机》本部分内容

2015-11-29 16:25:46 408

原创 我看Java虚拟机(3)---类文件结构

存储两种数据:无符号数和表。 魔数:4字节,识别文件,后缀是会被改变的,所以识别class文件是靠这四个字节。 版本号:2字节次版本号+2字节主版本号 常量池:2字节常量池中存放数据的个数len+len个常量顺序放置;11种数据类型1-12表示,标号2缺省(具体我也不知道为什么) 访问标志:2字节 类索引,父类索引,接口索引集合:2字节+2字节+若干字节,都索引向常量池的数据 字段数

2015-11-29 10:10:14 271

原创 我看Java虚拟机(2)---Java虚拟机内存区域详解

虚拟机内存区域的组成直接上图: 程序计数器:对于Java方法,用来选取下一条要执行的字节码;对于本地方法,值为空。线程独有虚拟机栈:执行Java方法,每一层都是一个栈帧,栈帧包括局部变量表、操作数栈、动态链接和方法出口等信息。线程独有本地方法栈:执行Native方法,sun HotSpot将其与虚拟机栈合二为一。堆:存放对象实例。堆分为新生代和老生代,新生代分为Eden区和两个Survivor

2015-11-24 23:14:19 418

原创 我看Java虚拟机(1)---Java简介(标配)和Java内存管理概述(空间)

先过下Java简介,然后内存管理Java简介有一下几点新认识:学习Java虚拟机目标:认清技术本质,才有资格去定义程序的质量Java技术体系:JDK(Java程序设计语言,API,虚拟机),class文件格式,第三方类库发展方向:模块化(eg:OSGI),混合语言(eg:JIN),balalala。。编译JDK,没来及做,错过就以后补吧! 好,标配写完收工!Java内存管理(概述)扯淡:

2015-11-24 22:52:04 200

原创 我看Java虚拟机(0)

学习了周志明老师的《深入理解Java虚拟机》,谨以此文章记录下我的所学所思。 由于习惯于全局到局部,所以我先呈现的是对Java虚拟机总体的一个把握,然后在一步一步解剖每个部分,话不多说,进入正题。总体分为空间和时间方面的知识: 空间:虚拟机工作的整个过程中,其使用到的内存状态变化; 时间:虚拟机工作流程,即虚拟机如何一步一步将代码转换到机器可执行的过程。 好了各位看官(假装自己是名博),引子

2015-11-24 20:48:00 228

空空如也

空空如也

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

TA关注的人

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