- 博客(10)
- 收藏
- 关注
转载 算法——Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money c
2016-11-18 13:59:55
376
转载 算法——First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.ja
2016-11-18 10:40:21
407
原创 算法——Patching Array
给定一个已排序的整数数组和一个值n,插入几个元素使得的可以组成的[1,n]中所有的数。求加入最小的数量元素完成该功能。 Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive
2016-11-17 09:01:01
448
转载 Python正则表达式指南
比较推荐这篇,http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html说的挺详细的。
2016-11-16 11:34:01
264
翻译 算法——Largest Rectangular Area in a HistogramLargest Rectangular Area in a Histogram
题目:给定的直方图中查找最大的矩形。假设每个数据的的宽度都为1,高度不同。例如:使用[6, 2, 5, 4, 5, 2,6],来表示 7个直返图,图中最大的矩形面积是12。 思路一: 对每个给定的数据的每个点按照顺序的左右各算一遍,最后对比每个点的最大值。python代码:class Solution: # @param height, a list of integer # @
2016-11-15 17:01:59
384
原创 scala(2) 变长参数 lazy 异常处理 数组Array Map tuple
可变长参数 声明参数类型后加* def union(s:Int*)={ var sum=0 for (i:Int sum+=i } sum } print(union(1,2,3,4,56,7))lazy懒加载 只有调用时候在会被加载,一般使用在消耗内存/CPU的时候使用。
2016-03-28 22:15:45
513
原创 scala(8)Actor
Actor 用于并行计算 ,Actor之间可以进行消息发送。 case class 是理想的载体,Actor的优势在于不基于资源与锁的基础上,完成并发。 Actor的建立import scala.actors._class ActorOps {}object helloActor extends Actor{ def act(): Unit ={ for (i1 t
2016-03-28 17:43:40
310
原创 scala(1) 函数 条件表达式 循环
scala传统类型: 类:class 默认是public权限 静态类:object 抽象类:abstract class 接口:trait 隐式变换:implicit 变量:var 修饰可变变量,val修饰不可变变量函数形式 def 函数名(变量名1:变量类型,变量名2:变量类型,……):返回类型={ 函数体 } scala 最后一行就的是返回值,但是也可以用
2016-03-26 20:24:39
1024
原创 学习笔记 提取常量和一个简单的聊天系统(python)from python基础教程
提取常量:将数据中的常量和配置常量保存的文件中,写程序时在文件中可以直接提取.txt[nember]pi: 3.1415926[message]greeting: welcome questing: put in radius:result: The area istest.pyfrom ConfigParser import ConfigPar
2015-10-22 14:39:31
469
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人