自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(31)
  • 资源 (6)
  • 收藏
  • 关注

原创 DP-MinAbsSum

给定一个数组N个正整数,给每个数一个符号,正或者负使得所有数的的和的绝对值尽可能大。也就是使得这个 val(A, S) = |sum{ A[i]*S[i] for i = 0..N−1 }尽可能大s[i] = +1或者-1。 通过分析可以发现元素的正负不影响结果,问题转化为将数分成两堆,两堆只差最小。首先将元素全部转成正数顺便做了个count sort. 发现这个问题转化为多重背包问题。 DP

2015-05-24 22:45:03 854

转载 最大公约数(Gcd)两种算法(Euclid && Stein)转载

写的不错,代码看起来很舒服。欧几里德算法和扩展欧几里德算法 欧几里德算法 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。其计算原理依赖于下面的定理:定理:gcd(a,b) = gcd(b,a mod b)证明:a可以表示成a = kb + r,则r = a mod b 假设d是a,b的一个公约数,则有 d|a, d|b,而r = a - kb,因此d|r 因此

2015-05-05 16:40:53 451

原创 9.1 ChocolatesByNumbers

N块巧克力摆成一个环从0到N-1。首先吃No.0块,然后吃掉No.M块,依次吃掉No.2M….直到遇到空的块,求可以吃掉几块。 求最小公倍数的问题。class Solution { public int solution(int N, int M) { // write your code in Java SE 8 // x*M % N = y*M %N

2015-05-04 20:54:51 404

原创 cargo center

将某城市划分为m*n个区域,每个区域货物量保存在二维数组。将每个区的货物送到一个cargo center,汽车只能上,下,左,右,四个方向移动。求center使所有货物运到这儿的cost最小。初中物理有道题,给你一块不均匀木板,如何找到它的重心。用一根绳吊起来,画一条垂直线,再换个地方吊起了画出垂直线。两线交叉的地方就是重心。 这道题也是一样,先找出最小的列使所有点到这一列的cost最小。再找到行

2015-05-04 10:48:48 603

原创 8.3 Peaks

A non-empty zero-indexed array A consisting of N integers is given.A peak is an array element which is larger than its neighbors. More precisely, it is an index P such that 0 < P < N − 1, A[P − 1] < A

2015-04-30 21:00:06 489

原创 8.4 Flags

// you can also use imports, for example: import java.util.*;// you can use System.out.println for debugging purposes, e.g. // System.out.println(“this is a debug message”);class Solution {

2015-04-30 16:59:13 466

原创 7.3 MaxDoubleSliceSum

求两相邻子数组和最大,两端是开区间。 这道思索了很久,觉得解法没问题但是性能测试只有两个通过。 有两个因素影响最大值,两端的边界及切分的位置。边界扫描的同时在段内调整slice位置保证maxL+maxR的和最大。策略是以右边界扫描为主,maxR+A[i-1]<0及A[slice]>A[i-1]时调整slice。 但是为什么不对呢??class Solution { public int

2015-04-23 21:21:25 467

原创 7.2 MaxSliceSum

求连续最大和子数组。与例子中不同的是,如果和为负返回最大的数而不是0.Solutution当maxCur+A[i]<0时,maxCur不能设置为0,因为如果所有值都小于0,得到错误结果。在之前程序的基础上,增加分段最大值为负的判断。class Solution { public int solution(int[] A) { int maxSum = Integer.MIN

2015-04-22 15:49:40 502

原创 7.1 MaxProfit

求股票最大收益。算法导论上的问题 A zero-indexed array A consisting of N integers is given. It contains daily prices of a stock share for a period of N consecutive days. If a single share was bought on day P and sold

2015-04-21 16:28:23 412

原创 6.2 Dominator

如果存在leader,返回其任意index,否则返回-1. A zero-indexed array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A. For example, consider

2015-04-18 22:13:28 411

原创 4.4 StoneWall

求一堵高低不平的墙,最少可以用多少块砖。砖可以是任意高度宽度的正方形。 You are going to build a stone wall. The wall should be straight and N meters long, and its thickness should be constant; however, it should have different heights

2015-04-17 21:24:56 636

原创 5.1 Brackets

(),[],{}配对的问题,使用stack的经典案例,不多说了。 强烈吐槽java泛型就是一坨屎。我又想换C#了,单就语言来说C#明显比java友好多了,后发优势吧。前浪都死在沙滩上了。最近的趋势是函数式编程语言。JS,D语言都有浓重的函数式味道class Solution { public int solution(String S) { // write your co

2015-04-16 15:05:50 359

原创 5.3 Fish eat fish

N voracious fish are moving along a river. Calculate how many fish are alive. You are given two non-empty zero-indexed arrays A and B consisting of N integers. Arrays A and B represent N voracious fis

2015-04-16 14:44:33 755

原创 5.2 Nesting

Determine whether given string of parentheses is properly nested. 需要注意空间复杂度为1,不能使用stack。 A string S consisting of N characters is called properly nested if: S is empty; S has the form “(U)” where U

2015-04-16 09:11:32 924

原创 4.4 NumberOfDiscIntersections

Compute intersections between sequence of discs. 数组A[i]保存以i为圆点,A[i]为半径的圆。求多少对圆至少有一个共同点。 Given an array A of N integers, we draw N discs in a 2D plane such that the I-th disc is centered on (0,I) and

2015-04-15 16:42:11 649

原创 4.2 Distinct

找出数组中出现不同元素的个数。import java.util.*;class Solution { public int solution(int[] A) { if(A.length==0) return 0; Arrays.sort(A); int size = 1; int former = 0; fo

2015-04-14 16:41:48 393

原创 4.1 MaxProductOfThree

Maximize A[P] * A[Q] * A[R] for any triplet (P, Q, R). 寻找数组A,三个数乘积的最大值。A non-empty zero-indexed array A consisting of N integers is given. The product of triplet (P, Q, R) equates to A[P] * A[Q] * A[R

2015-04-14 16:31:37 744

原创 3.3 MinAvgTwoSlice

求数组最小平均数子序列起始位置 A non-empty zero-indexed array A consisting of N integers is given. A pair of integers (P, Q), such that 0 ≤ P < Q < N, is called a slice of array A (notice that the slice contains at

2015-04-13 22:06:30 593

原创 3.2 CountDiv

Write a function: class Solution { public int solution(int A, int B, int K); } that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i

2015-04-10 09:31:43 478

原创 3.1 PassingCars

A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road. Array A contains only 0s and/or 1s: 0 represents a car tr

2015-04-09 21:15:30 679

原创 MissingInteger

Write a function: class Solution { public int solution(int[] A); } that, given a non-empty zero-indexed array A of N integers, returns the minimal positive integer that does not occur in A. For exam

2015-04-09 16:43:43 660

原创 MaxCounters

You are given N counters, initially set to 0, and you have two possible operations on them: increase(X) − counter X is increased by 1, max counter − all counters are set to the maximum value of any c

2015-04-09 15:38:43 483

原创 FrogRiverOne

A small frog wants to get to the other side of a river. The frog is currently located at position 0, and wants to get to position X. Leaves fall from a tree onto the surface of the river. You are give

2015-04-09 14:10:15 567

原创 1. PermCheck Check whether array A is a permutation.

A non-empty zero-indexed array A consisting of N integers is given. A permutation is a sequence containing each element from 1 to N once, and only once. For example, array A such that: A[0] = 4

2015-04-09 10:23:12 618

原创 MongoDB查询

基本查询不支持join,不能引用文档其他键的值。db.users.find({"username":"joe","age":27})返回部分文档 _id默认返回,除非明确指定不返回db.users.find({"username":"joe","age":27},{"username":1,"age":1,"_id":0})//1返回,0不返回查询条件$lt <$lte <

2015-03-18 16:59:33 455

原创 MongoDB Java Driver 3.0

connection数据库为每一个MongoDB数据库连接创建一个队列,一个连接可以保证先后顺序。 MongoClient自带连接池保持多个连接。DB and DBCollection are completely thread safe. In fact, they are cached so you get the same instance no matter what.我理解为对于每一个数

2015-03-18 11:21:43 2385 3

原创 运行MongoDB

启动一个DB非常简单,下载对应程序安装,在shell中启动mongod.exe。注意事项有2 1.需要预先创建数据目录,默认目录为c:\data\db。 2.确保27017端口没有被占用shell MongoDB自带一个JavaScript shell。shell启动后自动连接DB,可以使用多行命令。shell基本操作use egms//连接egms数据库db.getCollectionNa

2015-03-17 10:45:34 373

原创 MongoDB基本概念

文档(document)多个键值对组成的集合,可以认为是行。{“floorloc”: "FSA0001", "uid": 12345,"UID": 12345}//键区分大小写一个文档中不能有重复的键,区分大小写,所以上面uid,UID是不重复 .有特别意义,不要作为键名。.划分命名空间, .有特别意义,不要作为键名。.划分命名空间,类似JS,全局变量或函数 下划线_开头的键保留 文档中有一默

2015-03-17 09:53:20 342

原创 MongoDB创建,更新,删除

MongDB insert,update,delete

2015-03-04 10:12:27 420

原创 MongoDB 数据类型

MongoDB 支持jason的6种数据类型:null,布尔,数字,字符串,数组,对象 MongoDB包括三种数字类型(32位整数,64位整数,64位浮点数)符号,对象id,日期,正则表达式,javascript代码,二进制数据,BSON最大值,最小值,未定义(undefined),嵌套文档32位整数/64位整数 shell不支持,会自动转换为double 不要在shell中update整个文档

2015-02-26 15:56:34 442

转载 1 OSGi是什么:Java语言的动态模块系统

OSGi是什么OSGi亦称做Java语言的动态模块系统,它为模块化应用的开发定义了一个基础架构。OSGi容器已有多家开源实现,比如Knoflerfish、Equinox和Apache的Felix。您可以通过这些容器,把您的应用程序劈分为多个模块单元,这样,您就可以更容易地管理这些模块单元之间的交叉依赖关系。OSGi规范和Servlet规范及EJB规范类似,该规范定义了两种对象,一是

2014-09-28 17:05:53 461

货币金融学第9版-米什金-中文答案.pdf

货币金融学第9版-米什金-中文答案.pdf 。注意是习题答案!!! 作者: 弗雷德里克·S·米什金 出版社: 中国人民大学出版社 原作名: The economics of money, banking & financial markets 译者: 郑艳文 / 荆国勇 出版年: 2011-1 页数: 645 定价: 79.00元 装帧: 平装

2017-09-26

货币金融学第九版

货币金融学第九版中文版pdf。经典之作 作者: 弗雷德里克·S·米什金 出版社: 中国人民大学出版社 原作名: The economics of money, banking & financial markets 译者: 郑艳文 / 荆国勇 出版年: 2011-1 页数: 645 定价: 79.00元 装帧: 平装

2017-09-26

Java核心编程英文版

Core Java Volume 2 Advanced Topics.pdf 作者: Cay S. Horstmann / Gary Cornell 出版社: Prentice Hall PTR 出版年: 2004-12-02 页数: 1024 定价: USD 59.99 装帧: Paperback ISBN: 9780131118263

2017-09-26

七周七语言

七周七语言:理解多种编程范型pdf。 经典之作,不容错过 Ruby、Io、Prolog、Scala、Erlang、Clojure和Haskell这七种语言,关注每一门语言的精髓和特性

2017-09-26

Rational Robot user manual

Rational Robot user manual from IBM.

2009-02-19

如何使用Rational进行性能测试

如何使用Rational TestManager进行性能测试,注意事项

2009-02-19

空空如也

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

TA关注的人

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