摘要: 1 class Solution { 2 public boolean divisorGame(int N) { 3 boolean[] dp = new boolean[N + 3]; //初始化DP 4 dp[1] = false; //数字为1时失败 5 dp[2] = true; //数字为 阅读全文
posted @ 2020-07-24 23:15 小小码农-安 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public int minPathSum(int[][] grid) { 3 int row = grid.length; 4 int col = grid[0].length; 5 int[][] dp = new int[row][col]; 6 if 阅读全文
posted @ 2020-07-23 22:25 小小码农-安 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public int minArray(int[] numbers) { 3 int left = 0, right = numbers.length - 1; 4 while(left < right){ 5 int mid = (right - left 阅读全文
posted @ 2020-07-22 23:46 小小码农-安 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for a binary tree node. 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNode() {} 8 * Tre 阅读全文
posted @ 2020-07-21 23:04 小小码农-安 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public int[] twoSum(int[] numbers, int target) { 3 int len = numbers.length; 4 int left = 0, right = len - 1; 5 int[] res = new i 阅读全文
posted @ 2020-07-20 22:21 小小码农-安 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public int numWaterBottles(int numBottles, int numExchange) { 3 int res = numBottles; 4 while(numBottles / numExchange != 0) { 5 阅读全文
posted @ 2020-07-19 22:20 小小码农-安 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 解法一:暴力法 1 class Solution { 2 public boolean isInterleave(String s1, String s2, String s3) { 3 int index1 = 0, index2 = 0, index3 = 0; 4 if (check(s1, 阅读全文
posted @ 2020-07-18 22:52 小小码农-安 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public int searchInsert(int[] nums, int target) { 3 int length = nums.length; 4 int left = 0, right = length - 1, ans = 0; 5 whil 阅读全文
posted @ 2020-07-17 22:14 小小码农-安 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 private int[] num; 3 public boolean isBipartite(int[][] graph) { 4 num = new int[graph.length]; 5 Arrays.fill(num, -1); 6 for (in 阅读全文
posted @ 2020-07-16 22:50 小小码农-安 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public int numTrees(int n) { 3 int[] total = new int[n + 1]; 4 total[0] = 1; 5 total[1] = 1; 6 for (int i = 2; i <= n; ++i) { 7 f 阅读全文
posted @ 2020-07-15 22:31 小小码农-安 阅读(177) 评论(0) 推荐(0) 编辑