摘要: public int hammingWeight(int n) { //先将n转成二进制数? String num = Integer.toBinaryString(n); int count = 0; char[] c = num.toCharArray(); for (char value : 阅读全文
posted @ 2020-08-08 18:00 欣姐姐 阅读(96) 评论(0) 推荐(0) 编辑
摘要: public int cuttingRope(int n) { if(n<2) return 0; if(n == 2) return 1; if(n == 3) return 2; int times_of_3 = n/3; if(n%3 == 1){ times_of_3 --; } int t 阅读全文
posted @ 2020-08-08 17:16 欣姐姐 阅读(67) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int cuttingRope(int n) { int[] dp = new int[n+1]; dp[1] = 1; dp[2] = 1; for(int i = 3;i<=n;i++){ int x1 = i/2; int x2 = i - x1 阅读全文
posted @ 2020-08-08 16:33 欣姐姐 阅读(88) 评论(0) 推荐(0) 编辑
摘要: public int movingCount(int m, int n, int k) { //暴力法? boolean[][] visited = new boolean[m][n]; return move_count(m,n,k,0,0,visited); } private int move 阅读全文
posted @ 2020-08-08 15:20 欣姐姐 阅读(154) 评论(0) 推荐(0) 编辑