2013年3月22日
摘要: 参考:http://kevin-in-java.iteye.com/blog/1223149定义栈的数据结构,要求添加一个min函数,能够得到栈的最小元素。要求函数min、push以及pop的时间复杂度都是O(1)。核心思想:添加辅助栈,将最小值也添加到辅助栈,出栈时,如果是最小值,辅助栈也要出栈。备注:此处采用顺序栈,无法扩大存储面积,可参考链接日志采用链栈; 出栈的数据类型采用Integer考虑到可能出栈不成功,int无法满足,则以NULL表示无法出栈成功 要注意Integer和int的转换问题。 以及Integer.valueOf(int i), integer.equals... 阅读全文
posted @ 2013-03-22 23:01 nkxyf 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 参考:http://blog.sina.com.cn/s/blog_6b8b431d0100y8s0.htmlint a = 1;Integer b = 1;Integer c = new Integer(1);Integer d = Integer.valueOf(1); //Integer.valueOf(int i) 源码上是 进行范围判断后 采用 new Integer(i)方法System.out.println(a==b); // trueSystem.out.println(a==c); // trueSystem.out.println(a==d); ... 阅读全文
posted @ 2013-03-22 18:10 nkxyf 阅读(2055) 评论(0) 推荐(0) 编辑