摘要:
这题和之前做的一个滴滴魔法石题很像。解题步骤也基本一致 由于最低运力肯定是大于等于最大货物重量,小于等于所有货物相加的重量。所以直接二分查找 复杂度应该是NlogN class Solution { public int shipWithinDays(int[] weights, int D) { 阅读全文
摘要:
其实就是栈操作能否按照给定顺序输出 public static String getResult(int[] res){ if (res.length <= 2){ return "Yes"; } Deque<Integer> de = new LinkedList<>(); int s = 1; 阅读全文
摘要:
愚蠢的做法如下(我也差不多是这样做的。。。) public class Random23 { static int countWays(int p, int q, int r, int last) { if (p < 0 || q < 0 || r < 0) return 0; if (p == 1 阅读全文
摘要:
221 最大正方形 我的解法如下 class Solution { public int maximalSquare(char[][] matrix) { int[][] dp = new int[matrix.length][matrix[0].length]; //x,y代表xy为右上角的最大正 阅读全文
摘要:
684 冗余连接 不得不说并查集真的是一种很巧妙的思维了。。。 int[] visit; public int[] findRedundantConnection(int[][] edges) { visit = new int[edges.length+1]; for (int i = 0; i 阅读全文