上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 23 下一页
摘要: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12, 阅读全文
posted @ 2016-11-02 12:53 Black_Knight 阅读(1596) 评论(0) 推荐(0) 编辑
摘要: 在java中如果一个类被声明为静态的,那么只有一种情况,即这个类是内部类,外部类不能被声明为静态的。 1.静态内部类跟静态方法一样,只能访问静态的成员变量和方法,不能访问非静态的方法和属性,但是普通内部类可以访问任意外部类的成员变量和方法。 2.静态内部类可以声明普通成员变量和方法,而普通内部类不能 阅读全文
posted @ 2016-11-01 22:40 Black_Knight 阅读(1597) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 阅读全文
posted @ 2016-11-01 17:21 Black_Knight 阅读(714) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. Credits:Special thanks t 阅读全文
posted @ 2016-11-01 15:32 Black_Knight 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Implement int sqrt(int x). Compute and return the square root of x. 【题目分析】 这道题目要求求一个整数的开方数,而且结果是返回一个整数。 【思路】 一个整数x的开方整数是什么呢?假设结果是y,那么y*y <= x。 因为肯定存在y 阅读全文
posted @ 2016-10-31 10:30 Black_Knight 阅读(752) 评论(0) 推荐(0) 编辑
摘要: 1. 类的成员变量有默认初始化值。 2. 局部变量没有默认初始化值。 3. 局部变量和成员变量名称相同的时候,在方法调用的时候,采用就近原则。 4. 子类的构造方法默认会访问父类中的空参构造方法。 子类会继承父类的数据还可能会使用父类中的数据,所以子类在初始化之前要先初始化父类中的数据; 子类的构造 阅读全文
posted @ 2016-10-28 17:32 Black_Knight 阅读(160) 评论(0) 推荐(0) 编辑
摘要: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequence 阅读全文
posted @ 2016-10-28 13:13 Black_Knight 阅读(355) 评论(0) 推荐(0) 编辑
摘要: 本文参考了如下两篇文章: https://my.oschina.net/joymufeng/blog/139952 http://www.cnblogs.com/lwbqqyumidi/p/3700164.html Java中,经常可以遇到类型转换的场景,从变量的定义到复制、数值变量的计算到方法的参 阅读全文
posted @ 2016-10-27 21:39 Black_Knight 阅读(54068) 评论(3) 推荐(11) 编辑
摘要: Implement pow(x, n). 【题目分析】 实现幂指数函数。 【思路】 1. 防止overflow的发生 2. 减少时间复杂度 最简单的思路就是遍历啦,但是当n < 0时,有人会把n先变为-n,这样当n = Integer.MIN_VALUE是会产生溢出。 直接遍历相乘的时间复杂度很高, 阅读全文
posted @ 2016-10-27 11:40 Black_Knight 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1.什么是java的多态 浏览了别人博客中的一些介绍多态的文章,发现大家的描述有点不一样,主要区别在于是否把方法的重写算做多态。一种我比较认同的说法如下: 多态分为两种 a. 编译时多态:方法的重载; b. 运行时多态:JAVA运行时系统根据调用该方法的实例的类型来决定选择调用哪个方法则被称为运行时 阅读全文
posted @ 2016-10-27 10:58 Black_Knight 阅读(29091) 评论(1) 推荐(11) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 23 下一页