自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(78)
  • 资源 (1)
  • 收藏
  • 关注

原创 面向对象的四个基本特征和七大设计原则

基本特征封装客观事物抽象为类,有选择地隐藏和暴露数据和方法 比如有Person这个类,我希望隐藏我的年龄、工资等敏感信息,继承子类可以直接使用父类的部分数据和方法,可以有选择的扩展多态设计原则单一职责原则一个类应该仅有一个引起它变化的原因开放封闭原则对扩展开放,对更改封闭里氏替换原则子类必须能够替换父类所出现的任何地方

2017-09-16 18:53:15 7917

原创 Java8 HashMap源码解析

概述在官方文档中是这样描述HashMap的: Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key. (The HashMap cl

2017-08-04 15:54:19 5782 5

转载 oracle对汉字排序

汉字排序须综合考虑数据库字符集、NLS_SORT字符集查看数据库字符集:SELECT userenv('language') FROM dual;如果字符集为ZHS16GBK/ZH16GBK,那么使用order by默认是按照汉字的拼音顺序进行排序的;如果为其他(如UTF8),那么汉字的排序是按照BINARY排序的。 NLS_SORT当数据库字符集不为中文字符集时可设置NLS_SORT让其按照汉字拼

2017-08-01 14:51:49 1058

原创 Leetcode: Combination Sum

已知数组C和目标值T,要求在C中找出所有独特的组合使其和为T,C中所有的数和T都为正整数39. Combination SumNote: 1. C中无重复 2. 同一个数在组合中可以出现任意次比如C=[2, 3, 6, 7] ,T=7, 解为[ [7], [2, 2, 3]]解法简单回溯public class Solution { public List<List<Integ

2017-07-30 22:24:06 449

原创 421. Maximum XOR of Two Numbers in an Array

Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.Could you do this in O(n) runtime?题解使用trie树记录所有数的01二进制表示 之后遍历每个数,找

2017-07-22 21:45:06 287

原创 Eclipse中启动tomcat报错java.lang.OutOfMemoryError: PermGen space的解决方法

有的项目引用了太多的jar包,或者反射生成了太多的类,或有太多的常量池,就有可能会报java.lang.OutOfMemoryError: PermGen space的错误解决方案为通过添加下面的参数增加分配给JVM的内存空间-XX:MaxPermSize=256meclipse中配置tomcat的内存大小的方法点击“Run” – “Run Configurations…”,选中Tomcat Ser

2017-07-21 11:31:47 512

原创 在oracle下触发器实现主键自增

1. 利用序列产生主键值序列(Sequence)是一种可以被多个用户使用的用于产生一系列唯一数字的数据库对象。序列定义存储在数据字典中,通过提供唯一数值的顺序表来简化程序设计工作,可以使用序列自动产生主键的键值。当一个序列第一次被查询调用时,它将返回一个预定值。在随后的每次查询中,序列将产生一个按指定的增量增长的值。序列可以循环,或者是连续增加的,直到指定的最大值为止。 创建序列语法如下:creat

2017-07-13 00:45:49 1517

原创 用户增删改查:在eclipse创建Spring+SpringMVC+Mybatis的项目

1. 新建maven项目点击“File”->“New”->”Other”->输入“Maven”,新建一个“Maven Project”,如下图所示:请勾选“Create a simple project”,创建一个简单的项目。填写好包名、项目名,选择打包类型为:war,如下图所示项目创建好后可能会发现有错误,选择项目,右键“属性properties”->”层面Project Facets”-

2017-06-19 00:30:12 12889 12

原创 寻找和为定值的多个数

15.3SumGiven 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

2017-06-11 20:49:37 803 4

原创 477. Total Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Now your job is to find the total Hamming distance between all pairs of the given numb

2017-06-05 15:09:00 440

原创 547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A

2017-06-02 21:37:00 475

原创 503. Next Greater Element II

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 the first grea

2017-05-31 15:48:46 303

转载 ThreadPoolExecutor源码解析

本文出自 http://blog.csdn.net/rebirth_love/article/details/51954836#comments第一部分:ThreadPoolExecutor的继承结构根据上图可以知道,ThreadPoolExecutor是继承的AbstractExecutorService(抽象类)。再来看一下AbstractExecutorService的结构可以发现,Abst

2017-05-28 20:36:09 508

转载 并发,同步,异步,互斥,阻塞,非阻塞的理解

转载自 http://blog.csdn.net/it_lover_/article/details/52154591并发(concurrency)并发:在操作系统中,是指一个时间段中有几个程序都处于已启动运行到运行完毕之间,且这几个程序都是在同一个处理机上运行。其中两种并发关系分别是同步和互斥。互斥:是指某一资源同时只允许一个访问者对其进行访问,具有唯一性和排它性。但互斥无法限制访问者对资源的访

2017-05-23 22:16:48 1386

原创 设计模式之单例模式

1. 什么是单例模式该类只能有一个实例;该类能够自动实例化;对整个系统可见,即必须向整个系统提供这个实例。2. 实现a. 饿汉式public class Singleton { private static Singleton instance=new Singleton(); private Singleton(){ } public static

2017-05-23 17:49:32 312

转载 Java编程:删除 List 元素的三种正确方法

删除 List 中的元素会产生两个问题:删除元素后 List 的元素数量会发生变化;对 List 进行删除操作可能会产生并发问题;我们通过代码示例演示正确的删除逻辑package com.ips.list;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.

2017-05-23 16:08:31 1048

转载 Java字节流与字符流

字节流与字符流先来看一下流的概念:在程序中所有的数据都是以流的方式进行传输或保存的,程序需要数据的时候要使用输入流读取数据,而当程序需要将一些数据保存起来的时候,就要使用输出流完成。程序中的输入输出都是以流的形式保存的,流中保存的实际上全都是字节文件。字节流与字符流java中提供了专用于输入输出功能的包Java.io,其中包括:     InputStream,OutputStream,R

2017-05-23 15:06:08 512

原创 不用辅助内存交换两个数的值

首先先来看一下我们常用的交换算法,使用了一个辅助变量 void swap(int &a, int&b){ int temp = a; a = b; b = temp; }那么,怎么才能不用到这个辅助变量呢? 这里用到辅助变量是因为在更改a=b后要保留原有a的信息,如果想不用辅助变量,就要在已有的a和b中储存足够的信息。所以我们尝试在b中

2017-05-22 00:11:48 967

原创 526. Beautiful Arrangement

Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 ≤ i ≤

2017-05-20 16:14:11 262

原创 413. Arithmetic Slices

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:

2017-05-19 16:46:55 277

原创 406. Queue Reconstruction by Height

Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this p

2017-05-18 15:06:42 183

原创 7. Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed int

2017-05-15 15:11:28 183

原创 Activity使用技巧

知晓当前是在哪一个活动当我们需要看别人写的源码,但是不知道启动的是哪一个活动,就可以通过下面的方式。新建BaseActivity类继承AppCompatActivity,使所有活动继承BaseActivity类import android.support.v7.app.AppCompatActivity;import android.util.Log;public class BaseActivi

2017-05-14 16:17:38 280

原创 KMP算法

参考博客: 1. 经典算法研究系列:六、教你初步了解KMP算法、updated 2. KMP算法的前缀next数组最通俗的解释,如果看不懂我也没辙了字符串的匹配问题假设文本是一个长度为n的数组T[1…n],模式是一个长度为m<=n的数组P[1….m]。 找出所有在文本T=“abcabaabcaabac”中的模式P=“abaa”所有出现。 该模式仅在文本中出现了一次,在位移s=3处。简单的字

2017-05-12 21:43:32 463

原创 160. Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2       ↘

2017-05-08 00:19:05 163

原创 88. Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional

2017-05-06 17:22:21 296

转载 二叉树前序、中序、后序遍历非递归写法的透彻解析

本文转载自:http://blog.csdn.net/zhangxiangdavaid/article/details/37115355前言二叉树的三种遍历,递归写法只要理解思想,几行代码。可是非递归写法却很不容易。这里特地总结下,透彻解析它们的非递归写法。其中,中序遍历的非递归写法最简单,后序遍历最难。我们的讨论基础是这样的:    //Binary Tree Nodetypedef st

2017-05-01 20:40:11 108

原创 110. Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by

2017-04-30 16:38:45 331

原创 滑动窗口的最大值

给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4],2,6,2,5,1}, {2,[3,4,2],6,2,5,1}, {2,3,[4,2,6],2,5,1}, {

2017-04-25 16:21:42 487

原创 数据流中的中位数

如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。题解解法1使用插入排序维护一个排好序的vector数组,Insert时间复杂度O(n),GetMedian()时间复杂度O(1)class Solution {public: void Insert(int

2017-04-24 23:44:54 422

原创 序列化二叉树

请实现两个函数,分别用来序列化和反序列化二叉树题解序列化:前序遍历,节点为空用#表示,如{8,3,9,1,4}的表示结果为{8,3,1,#,#,4,#,#,9,#,#,} 反序列化:逗号分隔了每个节点,如果是#则为空,否则算出数值实例节点并递归其左右子树。/*struct TreeNode { int val; struct TreeNode *left; struct

2017-04-23 18:31:05 219

原创 二叉树中序遍历的下一个节点

给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针next。题解如果没有给出父节点可能真要中序遍历一次了,但既然给出了就不必那么麻烦了。 分两种情况: 1. 该节点存在右子节点,则下一个节点是右子树的最左节点。 2. 该节点不存在右子节点,则下一个节点是该节点的第一个父子关系为左的祖先节点中的父节点, 因为如果遍

2017-04-22 23:41:36 1733 1

原创 正则表达式匹配

请实现一个函数用来匹配包括’.’和’‘的正则表达式。模式中的字符’.’表示任意一个字符,而’‘表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串”aaa”与模式”a.a”和”ab*ac*a”匹配,但是与”aa.a”和”ab*a”均不匹配】题解注意两个匹配的特殊样例 1. “” , “.” 2. “”, “.*” 即字符串为’\

2017-04-21 12:33:04 238

原创 数组中重复的数

在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是重复的数字2或者3。题解解法1: set或hashclass Solution {public: // Parameters: //

2017-04-20 13:34:54 498

原创 孩子们的游戏(圆圈中最后剩下的数)

题目描述首先,让小朋友们围成一个大圈。然后随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,并且不再回到圈中,从他的下一个小朋友开始,继续0…m-1报数….这样下去….直到剩下最后一个小朋友获得神秘大奖,。请你试着想下,哪个小朋友会得到这份神秘大奖呢呢?(注:小朋友的编号是从0到n-1)题解解法1模拟环形链表 这里通过取模运算直

2017-04-19 15:15:37 368

原创 459. Repeated Substring Pattern

Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Englis

2017-04-16 02:34:11 328

原创 231. Power of Two

Given an integer, write a function to determine if it is a power of two.题解判断一个数是不是2的幂,即1,2,4,8……2^30(对int范围而言)解法1循环class Solution {public: bool isPowerOfTwo(int n) { //不大于0的肯定不是 if

2017-04-13 17:51:45 177

原创 202. Happy Number

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 squares of i

2017-04-12 13:06:34 222

原创 414. Third Maximum Number

Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1: Input: [3, 2, 1]

2017-04-07 16:28:45 154

原创 数字在排序数组中出现的次数

统计一个数字在排序数组中出现的次数。题解:解法1:遍历从前往后遍历一遍,找到k开始计数为1,到不是k时终止。 时间复杂度O(n)解法2:二分查找找出k第一次和最后一次出现的下标,相减 时间复杂度O(lgn)如果只查找一次,然后向左右遍历有几个,并没有改变时间复杂度,还是O(n)class Solution {public: int GetNumberOfK(vector<int> da

2017-04-05 12:47:22 325

pdf417条码参考及码字表

pdf417条码参考及码字表

2017-02-26

空空如也

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

TA关注的人

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