自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

K.Sun

用最简单的文字解释问题,用最少的步骤解决问题!

  • 博客(48)
  • 资源 (8)
  • 收藏
  • 关注

原创 设计模式之代理模式

代理——受委托代表当事人进行某种活动,百度百科中是这么解释动词代理的。其实我们在这里讨论的代理也差不多这个意思。买火车票,不想大老远跑到火车站,找个车票代售点买张就行了……这里的车票代售点就是代理。想做广告,找个代言人,刷刷脸,涨涨人气……这里的代言人也是代理。想看看外面的世界,通过某个代理服务器,绕过强大的GFW,上上非死不可,油管……这里的代理服务器也是代理。代理模式应用还是很广泛的,其中最广为

2016-10-31 22:53:43 253

原创 Linux下安装GitHub

安装GitHub打开终端,输入命令sudo apt -get install git git-core git-doc一路安装下去以后,输入下面命令:ssh-keygen -t rsa -C "[email protected]"注意这里会让你输入一些东西,首先要输入保存key的文件名,这个随便写啦Generating public/private rsa key pair.Enter file in

2016-10-31 12:12:48 6413

原创 从N个不同数字中等概率取出M个数字(N>=M)

这个问题本身不难理解,但是关键的地方是理解等概率,还有一个隐性的条件,那就是不能重复取。所以初步的想法是用Rand()在[0,N]范围内生成M个随机数字,万一里面有重复数字,那这就不好玩了。为了避免重复数字,那咱就给他生成随机的偏移量呗,假如我们当前取到的数字是a[i],生成一个随机数字r,那么我们下一个取得数字就是a[i+r]。可是这种做法也有点小问题,假如还没取完,然后数据就越界了,咋办?你可能

2016-10-29 09:21:50 3774

原创 提升数据库数据查询效率

1. 前言随着信息技术的发展,信息系统在企业中的应用也越来越广泛,信息系统在企业运营中扮演者十分重要的角色。可以说在信息化如此广泛的今天,企业信息化是提升企业运营效率的必经之路,数据是企业资产中必不可少的组成部分,数据组织效率的高低可能直接影响企业业务的进展,数据的安全则关系到整个企业的命运与兴亡。数据是系统重要的组成部分,数据库又是承载数据最重要的载体,那么数据库在整个信息系统的地位也是可想而知的

2016-10-29 08:29:01 2741

原创 Android SDK在线更新镜像服务器

想更新个Android SDK,也真是费劲,好歹天无绝人之路。打开Android SDK Manager,选择菜单tool下面的option,如下图: 要填的只有两个地方:一个是代理服务器地址,另一个是端口。 注意下面两个勾选项。中国科学院开源协会镜像站地址:IPV4/IPV6: mirrors.opencas.cn 端口:80IPV4/IPV6: mirrors.opencas.org 端口

2016-10-28 21:26:01 445

翻译 最小总距离点的最优位置

原文地址:Optimum location of point to minimize total distance已知一个点集合和一条直线ax+by+c = 0,我们要在直线上找到一个点,这个点到这个集合的每个点的距离和是最小的。例子:上图中直线x - y - 3 = 0的最优点是(2, -1),这个点与其他点的总距离是20.77,也就是最小的总距离啦。如果我们在这条直线的无线位置上取一个点,那么总

2016-10-28 20:03:01 2353

翻译 算法分析之渐近分析(Asymptotic Analysis)

原文地址:Analysis of Algorithms | Set 1 (Asymptotic Analysis)为什么要做性能分析?这里呢有许多东西需要考虑,比如用户的友好度,模块化,安全性,以及可维护性等等。为啥就不考虑考虑性能呢?答案很简单,如果我们拥有了性能,那么上面提到的东西也就有了。所以性能就像货币一样,用它我们可以买到上面提到的所有东西。另外学习性能的原因就是——速度超有趣!对一个任务

2016-10-25 21:33:26 10189 2

原创 用Intellij Idea从Github上获取代码

1、打开File菜单,选择Setting,在Version Control下找到Github。 2、分别在Login与Password中输入自己在Github注册的用户名和密码,然后点击Test按钮: 如果提示连接成功,那么说明这个账号是可用的。3、继续在这个目录下面找到Git 4、添加git.exe所在的正确目录,注意,这里的大前提是你要安装Git,安装完以后添...

2016-10-24 19:12:26 38268 4

翻译 动态规划之分区问题(Partition problem)

原文地址:Dynamic Programming | Set 18 (Partition problem)分区问题是将已知的集合分成两个子集,这两个子集的元素分别加和是相等的。例子:arr[] = {1, 5, 11, 5}Output: true 这个数组可以被分为:{1, 5, 5}和{11}arr[] = {1, 5, 3}Output: false 这个数组不能被分成两个和相同的子集

2016-10-24 18:12:39 9417

翻译 可排列的最长公共子序列(Longest common subsequence with permutations allowed)

原文地址:Longest common subsequence with permutations allowed已知两个小写的字符串。找出这两个字符串排过序后的公共子序列,输出的结果必须是排过序的。例子:Input : str1 = "pink", str2 = "kite"Output : "ik" 字符串"ik"是最长的有序字符串,它的其中的一个排列是"ik",而且是"pink"的子序列

2016-10-24 15:57:52 331

翻译 动态规划之递增子序列最大和(Maximum Sum Increasing Subsequence)

原文地址:Dynamic Programming | Set 14 (Maximum Sum Increasing Subsequence)已知一个含有n个正整数的数组,写一个程序能让其找到已知数组的子序列的最大和,也就是说子序列中的整数是递增排序的。例如,如果输入是:{1, 101, 2, 3, 100, 4, 5},那么输出应该就是106 (1 + 2 + 3 + 100),如果输入是:{3,

2016-10-20 09:26:30 2305

原创 设计模式之单例模式

单例模式应该是设计模式中最简单的模式了,所以经常被设计模式课程作为入门模式进行讲解。单例模式本身比较简单,其实也就是一句话,一次只能建一个对象实例,再看看代码示例就更清楚了。public class Singleton { private static Singleton instance; private Singleton (){} public static

2016-10-18 16:41:33 299

原创 设计模式之建造者模式(Builder)

啥叫建造者模式?就是说需要搞的这个玩意儿比较复杂,您要是一趟车就要搞定,貌似难度比较大。那咋办,你得像建大楼一样,一层层往上盖才行。或者说你得先从小零件搞起,然后慢慢组装,最后成为成品。举个例子:假如你要生产一台计算机(假设你有能力生产所有部件),那你得先搞个CPU吧,然后再得搞个主板吧(主板上你得搞这种芯片吧),然后你觉得显示效果不爽,你还得搞个显卡吧,然后电源啦,硬盘啦,机箱啦,显示器啦等等等等

2016-10-18 16:11:13 264

原创 设计模式之工厂模式

说到工厂,你可能会想到批量生产……想到这里,那么我觉得对工厂模式就理解的差不多了。还是举一个栗子吧。比如Lenovo集团不是生产各种本子嘛,首先呢,人家肯定不止生产一种本子,比如哈,这个厂子已经很高端了,想生产个啥,只要一输入名字,一按按钮,“滴”一声,本子就出来了。输入:“ThinkPad X1” 滴一声 输出一台ThinkPad X1笔记本输入:“V480” 滴一声 输出一台V480笔记本输

2016-10-18 14:31:59 210

原创 设计模式之适配器模式

适配器,我想大家都知道是什么玩意儿。就好比笔记本电脑的电源适配器,本来墙上那个模块直接提供出来的电压直接接上的话,笔记本有点受不了,那么就需要有个转换的工具,这就是适配器。再举个栗子,以前Nokia为王的手机时代,手机充电器与手机的接口那交个五花八门,于是市场上产生这么一种产品,一个插头,然后伸出N种接口,方便你为各种手机充电,这也是适配器。这几年水果vs安卓,水果有自己专有的USB数据线,安卓呢也

2016-10-18 13:57:15 260

翻译 动态规划之最长回文子字符串(Longest Palindromic Substring)

原文地址:Longest Palindromic Substring | Set 1已知一个字符串。找出这个字符串中的最长回文子字符串。例如,如果已知的字符串是:“forgeeksskeegfor”,那么输出的结果应该是:“geeksskeeg”。方法1 (暴力法) 最简单的方法就是检验每一个子字符串,看看它们到底是不是回文的。我们可以用三层循环,外面的两个循环根据固定的边角字符逐个找出所有的子字

2016-10-18 12:49:27 900

翻译 计算任意两个定点的最长路径

原文地址:Longest path between any pair of vertices已知一个城市连接图,它们之间是通过电缆连接的,这样的话任意两个城市之间都没有环路。我们需要在已知的这个城市图中找到两个城市之间最大长度的电缆。Input : n = 6 1 2 3 // Cable length from 1 to 2 (or 2 to 1) is 3

2016-10-18 10:11:45 2545

翻译 所有整数对之间的位差异数之和(Sum of bit differences among all pairs)

原文地址:Sum of bit differences among all pairs 已知一个有n个整数的数组,找出数组中任意两个元素组成的整数的位差异数的和。例子:输入: arr[] = {1, 2} 输出: 4 数组中所有的整数对:(1, 1), (1, 2) (2, 1), (2, 2) 位差异数之和 = 0 + 2 + 2 + 0 = 4 输入: arr[] = {1, 3, 5}

2016-10-17 18:41:28 356

原创 Linux环境中安装JDK

JDK安装到不同平台的方法大同小异,安装倒没啥,Windows环境鼠标一步步往下点就是了,Linux环境则是将下载好的jdk-8u101-linux-x64.tar.gz(纯属举例)解压出来,复制到相应的目录(一般是/usr/下)下就OK了,下来就都是配置环境变量了。Windows下的环境变量有系统变量与用户变量,顾名思义,系统变量就是登陆到该系统的所有用户都可以使用,而用户变量则只有当前用户可以使

2016-10-17 15:48:56 313

转载 What are the most important data structure and algorithms to prepare for Google Interview?

Stick to Basics. I would classify the following data structures as must knowLinked List - Single and DoublyStackQueuesBinary Search Trees or general Binary TreeHeapsBasic Graph Traversal and Short

2016-10-17 14:11:40 298

翻译 已知一个有重复字符的字符串,打印其所有不同的字符排列

原文地址:Print all distinct permutations of a given string with duplicates已知一个字符串,其中可能包括相同的字符。写一个函数打印这些字符的排列,但不能有重复的排列。例子:Input: str[] = "AB"Output: AB BAInput: str[] = "AA"Output: AAInput: str[] = "A

2016-10-17 13:50:21 870

翻译 已知一个字符串,输出它包含字符的所有排列(permutations)

原文地址:Write a program to print all permutations of a given string排列,也叫“排列数”或者“order”(这个咋译?),它是一个有序的列表S一对一下相关的。一个长度为n的字符串有n!种排序。下面是字符串“ABC”的排列: ABC ACB BAC BCA CBA CAB这里有一个基本的回溯方法可作为答案。// C program to p

2016-10-17 13:26:45 546

原创 Vim分屏显示

Vim是一种十分强大的文本编辑工具,在日常工作中,我们不仅用Vim去编辑代码,很多时候也需要用它去查看代码。在Sublime text中有个两列显示的功能,这样可以充分利用显示器的空间,来显示足够多的代码,从而提升编辑查看效率。既然Vim用起来这么爽,那Vim是否也有这样的分屏显示功能呢?答案是肯定的,使用起来也很简单,就是几个简单的命令而已。首先呢肯定是先打开一个文件啦: 直接在终端中敲命令:v

2016-10-17 11:11:00 2119

翻译 动态规划之硬币兑换(Coin Change)

原文地址:Dynamic Programming | Set 7 (Coin Change)已知N,如果我们想要换N分,而且每种S = { S1, S2, .. , Sm} 价值的硬币是不限数量的,那么我们有多少种方法来兑换?硬币的顺序是无所谓的。例如:N = 4,S = {1,2,3},,因此有四种答案: {1,1,1,1},{1,1,2},{2,2},{1,3}。所以输出应该是4。N = 10,

2016-10-17 10:22:50 5220

原创 C++类默认的成员函数与Java Object类中的成员函数

C++空类默认成员函数class EmptyCppClass{ public: EmptyCppClass(); // 缺省构造函数 EmptyCppClass( const EmptyCppClass& ); // 拷贝构造函数 ~EmptyCppClass(); // 析构函数 EmptyCppClass& operator=( const

2016-10-16 16:56:25 518

原创 给定链表中某个节点的指针,删除链表中的该节点

这个问题最初的想法就获得给点节点之前的节点的位置即可,但是这样做再仔细想想貌似意义不是很大,至少从面试的角度感觉到面试官不想从这个角度让面试者去考虑问题,所以这里又有一个投机取巧的办法。那就是节点中前后节点信息唯一区别的地方就是该节点的data域!!!!!哈哈,找到这个关键点那么问题就解决了,在给定指针的前提下直接删除后面节点,然后将后面节点的值赋给当前位置,大功告成!注:该源码是参考别人的。#in

2016-10-16 14:16:13 866

翻译 动态规划之最小带权路径(Min Cost Path)

原文地址:Dynamic Programming | Set 6 (Min Cost Path)已知一个成本矩阵cost[][],位置(m, n)的权重是cost[][],写一个函数,这个函数返回从(0, 0)到(m, n)的最小带权路径。矩阵的每个格子表示的是通过这个格子的代价。到达(m, n)的路径总代价是这条路上所有代价和(包括出发点和终点)。你只可以从当前的格子向下,向右,或者对角线移动到下

2016-10-16 11:31:51 4330

翻译 快速排序最坏的情况啥时候出现?

原文地址:When does the worst case of Quicksort occur?这个答案还得看枢轴(pivot)的选择策略。在快速排序的早期版本中呢,最左面或者是最右面的那个元素被选为枢轴,那最坏的情况就会在下面的情况下发生啦:1)数组已经是正序(same order)排过序的。 2)数组已经是倒序排过序的。 3)所有的元素都相同(1、2的特殊情况)因为这些案例在用例中十分常见

2016-10-16 10:42:42 43120 1

翻译 迭代的快速排序(Iterative Quick Sort)

原文地址:Iterative Quick Sort 译者注:教科书中一般介绍的是递归的快速排序,当年在百度校招面试的时候被问到这个问题,没写出来,真是遗憾……下面是一种典型的递归的实现,用最后一个元素作为枢轴(pivot)/* A typical recursive C/C++ implementation of QuickSort *//* This function takes last e

2016-10-16 10:12:21 5260

翻译 动态规划之编辑距离(Edit Distance)

原文地址:Dynamic Programming | Set 5 (Edit Distance) 已知两个字符串str1与str2,str1可以用下面的操作。得到最小的编辑数使得str1转变为str2。 a)insert b)remove c)replace 以上所有的操作成本是一样的。例子:Input: str1 = "geek", str2 = "gesek"Output: 1

2016-10-15 20:51:41 1834

翻译 动态规划之最长公共子序列(Longest Common Subsequence)

原文地址:Dynamic Programming | Set 4 (Longest Common Subsequence) 我们已经分别在第一篇、第二篇文章中讨论了重复的子问题与最优的子结构。我们也在第三篇文章中讨论了一个例子。下来我们讲一个最长公共子序列(LCS)作为本文用动态规划来解决的例子问题。LCS问题描述:已知两个序列,找到同时是两个序列且长度最长的子序列。一个子序列是指与一个序列有相同

2016-10-15 16:14:42 842

翻译 Java中的迭代器(Iterators in Java)

原文地址:http://www.geeksforgeeks.org/iterators-in-javaIterators are used in Collection framework in Java to retrieve elements one by one. There are three iterators.枚举:枚举是一种用于从遗留下来的集合(Vector,HashTable)中获取元

2016-10-15 13:04:26 2133

原创 Ubuntu 16.04中安装Vim 8.0

Ubuntu 16.04中安装Vim 8.0Vim 8.0已经发布了,但是各个Linux发行商还没发行自己的官方源,但是我们可以安装非官方版本,不过这么干不太安全,所以测试环境中或者自己简单地玩玩就行了。很简单,打开终端输入以下命令:sudo add-apt-repository ppa:jonathonf/vimsudo apt updatesudo apt install vim安装完以后打

2016-10-15 12:53:59 7817

翻译 Java中的迭代器(Iterators in Java)

原文地址:http://www.geeksforgeeks.org/iterators-in-javaIterators are used in Collection framework in Java to retrieve elements one by one. There are three iterators.枚举:枚举是一种用于从遗留下来的集合(Vector,Has

2016-10-14 21:52:47 765

翻译 输出一个集合所有子集的元素和(Print sums of all subsets of a given set)

原文地址:http://www.geeksforgeeks.org/print-sums-subsets-given-set/Given an array of integers, print sums of all subsets in it. Output sums can be printed in any order.Input : arr[] = {2, 3}Outpu

2016-10-14 15:22:02 1051

原创 Java访问类中的私有成员(private member)

一般而言,一个类只允许访问另一个类中的public然而当我们非要访问私有成员的时候,这时候Java的反射机制就用得上了。package com.comac.reflect;public class A { private String testStr="just for test"; private void get(int index, String value)

2016-10-13 22:36:40 9642

翻译 获取数组中K个最大元素(k largest(or smallest) elements in an array | added Min Heap method)

原文地址:http://www.geeksforgeeks.org/k-largestor-smallest-elements-in-an-array/Question: Write an efficient program for printing k largest elements in an array. Elements in array can be in any order.

2016-10-13 19:49:59 880

翻译 最小树高的根(Roots of a tree which give minimum height)

原文地址:http://www.geeksforgeeks.org/roots-tree-gives-minimum-height/Given an undirected graph, which has tree characteristics. It is possible to choose any node as root, the task is to find those no

2016-10-13 17:56:42 561

原创 在数组中找出四个数字的和等于指定数字(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: The solution

2016-10-13 13:44:05 2990

原创 SQL删除表中的重复记录(多个字段),只留一条。

在一家韩国电商的面试中被问到了,当时一脸懵逼,没想法……回来想了想,还是有些思路的……唉……临场真是弱啊……第一步:查询重复记录SELECT * FROM TableNameWHERE RepeatFiled IN ( SELECT RepeatFiled FROM TableName GROUP BY RepeatFiled HAVING COUNT(RepeatFiled

2016-10-13 13:35:29 9796 1

Spring Data

As a developer of Java enterprise applications, you can choose among several data access frameworks when working with relational databases. But what do you turn to when working with newer technologies such as NoSQL databases and Hadoop? This book shows you how Spring's data access framework can help you connect to either non-relational or relational databases, or a combination of the two. You'll learn how Spring Data's familiar and consistent programming model greatly reduces the learning curve for creating applications with newer data access technologies. And you'll discover how to use Spring Data's improved JPA and JDBC support to increase your productivity when writing RDBMS-based data access layers. Relational database technologies continue to be predominant in the enterprise, but they're no longer considered a 'one size fits all' solution. This book shows you how to increase your options.

2017-10-05

OSGi in Action

HIGHLIGHT OSGi in Action is the definitive guide to OSGi, the hottest technology available for creating modular enterprise Java applications. DESCRIPTION What is OSGi? Simply put, OSGi is a standardized technology that allows developers to create the highly modular Java applications that are required for enterprise development. OSGi lets you install, start, stop, update, or uninstall components without taking down your entire system. The interest in OSGibased applications has exploded since major vendors like Sun, Spring, Oracle, BEA, and IBM have gotten behind the standard. OSGi in Action is a comprehensive guide to OSGi with two primary goals. First, it provides a clear introduction to OSGi concepts with examples that are relevant both for architects and developers. Then, it explores numerous practical scenarios and techniques, answering questions like: How much of OSGi do you actually need? How do you embed OSGi inside other containers? What are the best practices for moving legacy systems to OSGi? KEY POINTS Highly-visible authors and reviewers are core members of OSGI community. This book is based on hands-on experience with OSGI. Authors have contributed to high-profile OSGi implementations, including Apache Felix.

2017-10-05

C++编程思想 两卷合订本

(美)Bruce Eckel 著 刘宗田 袁兆山 潘秋菱 等译

2017-10-01

iOS编程 第四版

作者[美] Christian Keur / [美] Aaron Hillegass / [美] Joe Conway

2017-10-01

apt-mirror-api-0.1.jar

Files contained in apt-mirror-api-0.1.jar: META-INF/MANIFEST.MF META-INF/maven/com.moparisthebest.aptIn16/apt-mirror-api/pom.properties META-INF/maven/com.moparisthebest.aptIn16/apt-mirror-api/pom.xml com.sun.mirror.apt.AnnotationProcessor.class com.sun.mirror.apt.AnnotationProcessorEnvironment.class com.sun.mirror.apt.AnnotationProcessorFactory.class com.sun.mirror.apt.AnnotationProcessorListener.class com.sun.mirror.apt.AnnotationProcessors.class com.sun.mirror.apt.Filer.class com.sun.mirror.apt.Messager.class com.sun.mirror.apt.RoundCompleteEvent.class com.sun.mirror.apt.RoundCompleteListener.class com.sun.mirror.apt.RoundState.class com.sun.mirror.declaration.AnnotationMirror.class com.sun.mirror.declaration.AnnotationTypeDeclaration.class com.sun.mirror.declaration.AnnotationTypeElementDeclaration.class com.sun.mirror.declaration.AnnotationValue.class com.sun.mirror.declaration.ClassDeclaration.class com.sun.mirror.declaration.ConstructorDeclaration.class com.sun.mirror.declaration.Declaration.class com.sun.mirror.declaration.EnumConstantDeclaration.class com.sun.mirror.declaration.EnumDeclaration.class com.sun.mirror.declaration.ExecutableDeclaration.class com.sun.mirror.declaration.FieldDeclaration.class com.sun.mirror.declaration.InterfaceDeclaration.class com.sun.mirror.declaration.MemberDeclaration.class com.sun.mirror.declaration.MethodDeclaration.class com.sun.mirror.declaration.Modifier.class com.sun.mirror.declaration.PackageDeclaration.class com.sun.mirror.declaration.ParameterDeclaration.class com.sun.mirror.declaration.TypeDeclaration.class com.sun.mirror.declaration.TypeParameterDeclaration.class com.sun.mirror.type.AnnotationType.class com.sun.mirror.type.ArrayType.class com.sun.mirror.type.ClassType.class com.sun.mirror.type.DeclaredType.class com.sun.mirror.type.EnumType.class com.sun.mirror.type.InterfaceType.class com.sun.mirror.type.MirroredTypeException.class com.sun.mirror.type.MirroredTypesException.class com.sun.mirror.type.PrimitiveType.class com.sun.mirror.type.ReferenceType.class com.sun.mirror.type.TypeMirror.class com.sun.mirror.type.TypeVariable.class com.sun.mirror.type.VoidType.class com.sun.mirror.type.WildcardType.class com.sun.mirror.util.DeclarationFilter.class com.sun.mirror.util.DeclarationScanner.class com.sun.mirror.util.DeclarationVisitor.class com.sun.mirror.util.DeclarationVisitors.class com.sun.mirror.util.Declarations.class com.sun.mirror.util.SimpleDeclarationVisitor.class com.sun.mirror.util.SimpleTypeVisitor.class com.sun.mirror.util.SourceOrderDeclScanner.class com.sun.mirror.util.SourcePosition.class com.sun.mirror.util.TypeVisitor.class com.sun.mirror.util.Types.class

2016-11-15

《Java编程思想 第四版》源码

《Java编程思想 第四版》源码

2016-11-15

空空如也

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

TA关注的人

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