摘要:
this this是自身的一个对象,代表对象本身,可以理解为:指向对象本身的一个指针。 this的用法在java中大体可以分为3种: 1.普通的直接引用 这种就不用讲了,this相当于是指向当前对象本身。 2.形参与成员名字重名,用this来区分: class Person { private in 阅读全文
摘要:
思路分析:判断N是不是负数 1.正数、负数统一处:把int型转成二进制的string类型,再统计string类型中1的个数 public class Solution { public int NumberOf1(int n) { int count=0; String s=Integer.toBi 阅读全文
摘要:
斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。 1.递归法 时间复杂度:O(2^n) public class Solution { public int Fibonacci(int n) { if(n==0) return 0; if(n==1) re 阅读全文