摘要:
母牛的故事 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); wh 阅读全文
摘要:
位1的个数 解法一: class Solution { // you need to treat n as an unsigned value public int hammingWeight(int n) { return Integer.bitCount(n); } } 解法二: 记住一点,前面 阅读全文
摘要:
Fizz Buzz class Solution { public List<String> fizzBuzz(int n) { List<String> list=new LinkedList<>(); for (int i = 1; i <=n; i++) { if (i%3==0&&i%5== 阅读全文
摘要:
爬楼梯:斐波那契数列 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 非递归解法 class Solution { public int climbStairs(int n) { if (n==1 阅读全文