摘要: 题目源于题目来源于leetcode 题目 括号生成 数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。 提示: 1 <= n <= 8 解题思路:利用深度优先遍历,采用递归的方法,左括号大于零的时候继续产生左分支;左右括号数都为0时返回。 代码实现 pub 阅读全文
posted @ 2022-08-09 23:13 recklessh 阅读(37) 评论(0) 推荐(0)
摘要: 题目来源于leetcode 题目 种花问题 提示: 1 <= flowerbed.length <= 2 * 104 flowerbed[i] 为 0 或 1 flowerbed 中不存在相邻的两朵花 0 <= n <= flowerbed.length 解题思路:利用初始条件即不可能有相邻的花,在 阅读全文
posted @ 2022-07-28 22:07 recklessh 阅读(24) 评论(0) 推荐(0)
摘要: HashSet实现了Set接口,底层使用HashMap存储元素 HashSet源码: HashSet中的构造方法: private transient HashMap<E,Object> map; // Dummy value to associate with an Object in the b 阅读全文
posted @ 2022-07-25 22:00 recklessh 阅读(428) 评论(0) 推荐(0)