摘要:
单例模式 饿汉式 public class Singleton{ private static Singleton instance = new Singleton(); private Singleton(){} public static Singleton newInstance(){ ret 阅读全文
摘要:
哲学家进餐问题 有五个哲学家,他们共用一张圆桌,分别坐在五张椅子上。在圆桌上五支筷子,平时一个哲学家进行思考,饥饿时便试图取用其左、右最靠近他的筷子,只有在他拿到两支筷子时才能进餐。进餐完毕,放下筷子又继续思考。 代码模拟 public class Philosopher extends Threa 阅读全文
摘要:
滑动窗口总结 解决数组/字符串的子元素问题 3. 无重复字符的最长子串 class Solution { public int lengthOfLongestSubstring(String s) { // 滑动窗口 Set<Character> occ = new HashSet<>(); int 阅读全文