上一页 1 2 3 4 5 6 7 ··· 32 下一页
摘要: For example:Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) 首先我们要明确传统IP 地址的规律是分4个Part,每个Part是从0-255的数字 0-255 阅读全文
posted @ 2023-05-18 21:13 MarkLeeBYR 阅读(400) 评论(0) 推荐(0)
摘要: public String fun(String a, String b) { if (a.length() > b.length()) { return sub(a, b); } else if (a.length() < b.length()) { return "-" + sub(b, a); 阅读全文
posted @ 2023-05-11 15:54 MarkLeeBYR 阅读(109) 评论(0) 推荐(0)
摘要: public String add(String s1, String s2) { int m = s1.length(); int n = s2.length(); int carry = 0; StringBuilder sb = new StringBuilder(); for (int i 阅读全文
posted @ 2023-05-10 20:49 MarkLeeBYR 阅读(23) 评论(0) 推荐(0)
摘要: public static int subArrayCount(int[] arr) { if (arr == null) { return 0; } int count = 0; int len = arr.length; //对于每一个i位置都求一遍他有多少个子数组(这里可以通过数学方法计算即可 阅读全文
posted @ 2023-05-06 00:31 MarkLeeBYR 阅读(79) 评论(0) 推荐(0)
摘要: public int subarraySum(int[] nums, int k) { if(nums == null || nums.length < 1){ return 0; } int count = 0; int len = nums.length; for(int i = 0; i < 阅读全文
posted @ 2023-05-06 00:28 MarkLeeBYR 阅读(45) 评论(0) 推荐(0)
摘要: dp[i][0] 表示第i天持有股票所得现金 dp[i][1] 表示第i天不持有股票所得最多现金 如果第i天持有股票即dp[i][0], 那么可以由两个状态推出来。 1、第i-1天就持有股票,那么就保持现状,所得现金就是昨天持有股票的所得现金 即:dp[i - 1][0] 2、第i天买入股票,所得现 阅读全文
posted @ 2023-05-02 00:00 MarkLeeBYR 阅读(57) 评论(0) 推荐(0)
摘要: 给你一棵以 root 为根的二叉树和一个 head 为第一个节点的链表。 如果在二叉树中,存在一条一直向下的路径,且每个点的数值恰好一一对应以 head 为首的链表中每个节点的值,那么请你返回 True ,否则返回 False 。 一直向下的路径的意思是:从树中某个节点开始,一直连续向下的路径。 p 阅读全文
posted @ 2023-04-18 10:56 MarkLeeBYR 阅读(31) 评论(0) 推荐(0)
摘要: 定义一个二维数组: int maze[n][m]; 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 int maze[6][7] = {0, 0, 0, 0, 0, 0, 0,0, 1, 1, 1, 1, 1, 0,0, 阅读全文
posted @ 2023-04-17 23:09 MarkLeeBYR 阅读(111) 评论(0) 推荐(0)
摘要: 不修改原来树的结构 public TreeNode mergeTrees(TreeNode t1, TreeNode t2) { if (t1 == null) { return t2; } if (t2 == null) { return t1; } // 先合并根节点 TreeNode root 阅读全文
posted @ 2023-04-13 11:25 MarkLeeBYR 阅读(17) 评论(0) 推荐(0)
摘要: 字符串内容:1 + 2 * 5 - 6 / 2 写代码求出该字符串的值 class Main { private static final Map<String, Integer> map = new HashMap<>(); private void initMap() { map.put("+" 阅读全文
posted @ 2023-04-12 21:07 MarkLeeBYR 阅读(43) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 32 下一页