上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 35 下一页
摘要: public static int a() { int target = 6; int[] a = {3, 3, 1, 3, 3, 7, -1}; int[] dp = new int[a.length + 1]; //初始化 dp[0] = 0; for (int i = 1; i < dp.le 阅读全文
posted @ 2020-07-14 10:42 使用D 阅读(218) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int startI = 0; int endI = a.length - 1; while (startI <= endI) { 阅读全文
posted @ 2020-07-14 00:36 使用D 阅读(159) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { int target = 10; int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int startI = 0; int endI = a.length - 1; while (s 阅读全文
posted @ 2020-07-14 00:34 使用D 阅读(143) 评论(0) 推荐(0) 编辑
摘要: static class Node { private Node next; private int val; public Node(Node next, int val) { this.next = next; this.val = val; } public Node getNext() { 阅读全文
posted @ 2020-07-14 00:28 使用D 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 判断单链表是否有环,如果有环的话,具体再有环的节点是哪个? static class Node { private Node next; private int val; public Node(Node next, int val) { this.next = next; this.val = v 阅读全文
posted @ 2020-07-14 00:22 使用D 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 通过快慢指针方式对数组进行去重 public static void main(String[] args) { int[] a = {1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 8, 9, 10, 11}; int startI = 0; int 阅读全文
posted @ 2020-07-14 00:03 使用D 阅读(415) 评论(0) 推荐(0) 编辑
摘要: 获得素数:只能被1与自己整除的正整数? public static void main(String[] args) { boolean[] n = new boolean[100]; Arrays.fill(n, true); for (int i = 2; i * i < n.length; i 阅读全文
posted @ 2020-07-13 23:50 使用D 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 挖金矿(背包问题) /** * RUN THIS */ public static void main(String[] args) { System.out.println(d()); } public static int d() { int[] person = {5, 5, 3, 4, 3} 阅读全文
posted @ 2020-07-11 22:33 使用D 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 说明:每次只能向下或者向右移动一步。 举例: 输入: arr = [ [1,3,1], [1,5,1], [4,2,1] ] 输出: 7 解释: 因为路径 1→3→1→1→1 的总和最小。 pu 阅读全文
posted @ 2020-07-10 22:45 使用D 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 问总共有多少条不同的路径? public static int b() { int m = 1; int n 阅读全文
posted @ 2020-07-10 19:02 使用D 阅读(137) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 35 下一页