05 2023 档案

摘要:一、库存扣减逻辑 1)依赖缓存不依赖数据库,因为缓存能抗更高的tps。纯redis实现可能带来的问题:a、如果redis server实际扣减成功了,但是redis client接口返回失败。可能导致库存的浪费。怎么解决?可以加入库存数据库,每次更新redis成功后再更新数据库,如果redis更新失 阅读全文
posted @ 2023-05-19 19:01 MarkLeeBYR 阅读(54) 评论(0) 推荐(0) 编辑
摘要: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 阅读(351) 评论(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 阅读(103) 评论(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 阅读(15) 评论(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 阅读(69) 评论(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 阅读(29) 评论(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 阅读(48) 评论(0) 推荐(0) 编辑