上一页 1 ··· 5 6 7 8 9
摘要: sliding window使用场景: 求最大和/最大乘积时,如果元素均为正数时,可以使用sliding window 当出现负数时,就不能用了 滑动窗口模版: public int lengthOfLongestSubstringTwoDistinct(String s) { Map<Charac 阅读全文
posted @ 2021-10-04 08:54 xiaoyongyong 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 236. Lowest Common Ancestor of a Binary Tree Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to t 阅读全文
posted @ 2021-09-30 11:14 xiaoyongyong 阅读(89) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { 阅读全文
posted @ 2021-09-27 00:03 xiaoyongyong 阅读(41) 评论(0) 推荐(0) 编辑
摘要: Senario: 1) one to one send message 2) sent/deleveried/read 3) user online status , online/last seen 5min 4) send image, video,file 5) group chat DAU: 阅读全文
posted @ 2021-09-26 02:45 xiaoyongyong 阅读(394) 评论(0) 推荐(0) 编辑
摘要: 169. Majority ElementGiven an array nums of size n, return the majority element.The majority element is the element that appears more than ?n / 2? tim 阅读全文
posted @ 2021-09-25 23:16 xiaoyongyong 阅读(30) 评论(0) 推荐(0) 编辑
摘要: public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode() {} TreeNode(int val) { this.val = val; } TreeNode(int val, TreeNode left, T 阅读全文
posted @ 2021-09-16 21:44 xiaoyongyong 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 数组实现方式(类似与heap的实现方式): class NumArray { int[] arr=null; int len = 0; public NumArray(int[] nums) { len = nums.length; arr = new int[len*10]; buildSegTr 阅读全文
posted @ 2021-09-12 23:31 xiaoyongyong 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 单例模式3要素“ 1.构造私有,防止外部直接new对象 2.定义静态成员类变量 3.提供静态方法 饿汉式: public class SingleTon{ private static SingleTon singleTon = new SingleTon(); private SingleTon( 阅读全文
posted @ 2021-08-27 21:42 xiaoyongyong 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 主题: 设计一个分布式的缓存系统(类似redis) Senario 分析: 功能需求: put(key,value) get(key) 非功能需求: QPS: 10million/second Service : API: 1) POST : put(key,value) 2) GET : get( 阅读全文
posted @ 2021-08-17 09:32 xiaoyongyong 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 1.why do we consist hashing? problem: if we just use the normal hashing, for example, firstly we have 3 nodes in our db system, all the hashcode%3==0 阅读全文
posted @ 2021-08-17 08:40 xiaoyongyong 阅读(39) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9