题目描述
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary t...
分类:
其他好文 时间:
2015-06-06 12:10:56
阅读次数:
131
题目描述
Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.
For example:
Given the below binary tree and sum = 22, 5
/ \...
分类:
其他好文 时间:
2015-06-06 12:09:10
阅读次数:
117
想要明白hashCode的作用,必须要先知道java中的集合。(不明白的请看Java基础之集合框架详解(二)List篇和Java基础之集合框架详解(三)Set篇)
Java中的Collection集合有两类,一类是List,另一类是Set,前者集合内的元素是有序的,元素可以重复;后者元素无序且元素不可重复。而我们通常使用Object.equals方法来判断两个元素是否重复。即当我们想查找一个元素中是...
分类:
编程语言 时间:
2015-06-05 15:53:17
阅读次数:
153
主题
永远也不要使用string.equals(“”)检验一个字符串是空串
最优方案
检验字符串是空串的最好方法是:用length(),这个方法返回字符串中字符的个数,如果字符的个数是0,一定是空串。public boolean isEmpty(String str)
{
return str.equals(""); //NEVER do this
}public boo...
分类:
其他好文 时间:
2015-06-05 12:21:17
阅读次数:
104
几个corner cases要清楚refhttp://www.cnblogs.com/springfor/p/3869666.html引用一个用法注意“判断字符串相等与否要用.equals(),因为是引用类型。要注意split函数是可以split出空字符的,例如://b/ 会被split结果为[""...
分类:
其他好文 时间:
2015-06-05 06:24:33
阅读次数:
112
public class Worker {private int id; private String name; private double salary; public boolean equals(Object o){ ...
分类:
其他好文 时间:
2015-06-04 20:49:32
阅读次数:
109
package Test;import demo.Student;public class TestStudent { public static void main(String[] args) { Student str1=new Student("李四","31岁"); S...
分类:
其他好文 时间:
2015-06-04 13:39:21
阅读次数:
82
转http://blog.sina.com.cn/s/blog_48cd37140101awgq.htmlJava中判断String不为空的问题一、判断一个字符串str不为空的方法有: 1. str!=null; 2. "".equals(str); 3. str.length()!=0;(注意:l...
分类:
其他好文 时间:
2015-06-03 17:25:00
阅读次数:
84
MAP Map用于保存具体映射关系的数据,因此Map集合里保存着两组值,一组值用于保存Map里的key,另外一组值用于保存Map里的value,key和value都可以是任意类型的数据。Map的key不允许重复,即同一个Map对象的任何两个key通过equals方法比较总是返回false。map接....
分类:
编程语言 时间:
2015-06-03 17:18:41
阅读次数:
125
Set(1)Set集合的特点 无序(存入和取出顺序),唯一 (2)HashSet集合 A:底层数据结构是哈希表(是一个元素为链表的数组) B:哈希表底层依赖两个方法:hashCode()和equals() 执行顺序: 首先比较哈希值是否相同 相同...
分类:
编程语言 时间:
2015-06-03 15:32:07
阅读次数:
128