
leetcode
DJames23
这个作者很懒,什么都没留下…
展开
-
【动态规划】买卖股票问题
参考: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/solution/tan-xin-suan-fa-by-liweiwei1419-2/原创 2021-08-19 23:39:11 · 280 阅读 · 0 评论 -
【连通图】322无向图中连通分量的数目
无向图中连通分量的数目 注意: 你可以假设在 edges 中不会出现重复的边。而且由于所以的边都是无向边,[0, 1] 与 [1, 0] 相同,所以它们不会同时在 edges 中出现。 答案: class Solution { public int countComponents(int n, int[][] edges) { Union u = new Union(n); for(int[] nums : edges){ int a.原创 2021-08-14 11:41:58 · 716 阅读 · 0 评论 -
【leetcode】146.LRU缓存机制
参考: https://leetcode-cn.com/problems/lru-cache/solution/lruhuan-cun-ji-zhi-by-leetcode-solution/ LRU算法 1.双向链表+HashMap实现 参考题解: https://leetcode-cn.com/problems/lru-cache/solution/lru-ce-lue-xiang-jie-he-shi-xian-by-labuladong/ import java.util.HashMap; impo原创 2021-07-18 17:25:50 · 152 阅读 · 0 评论 -
【leetcode】贪心算法
原创 2021-07-17 17:29:57 · 147 阅读 · 0 评论 -
【leetcode】HOT100第234题:回文链表
package Hot100; import java.util.ArrayList; import java.util.List; /** * leetcode HOT100 第234题 回文链表 * @author dengjie * @create 2021-05-24 21:05 */ public class Solution234 { public static void main(String[] args) { ListNode node1 = new L原创 2021-05-24 22:27:39 · 160 阅读 · 0 评论 -
【leetcode】HOT100-第46题全排列
全排列: HOT100-第46题 package Hot100; import java.util.ArrayList; import java.util.List; /** * leetcode HOT100第46题:全排列 * 给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。 * * @author dengjie * @create 2021-05-23 12:40 */ public class Solution46 { pu原创 2021-05-23 14:45:28 · 218 阅读 · 0 评论 -
【leetcode】17题:电话号码的字母组合
参考博客: https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/solution/tong-su-yi-dong-dong-hua-yan-shi-17-dian-hua-hao-m/ import java.util.ArrayList; import java.util.List; /** * leetcode17:电话号码的字母组合 * 题目:给定一个仅包含数字2-9的字符串,返回所有它能表示的字母组合。答原创 2021-04-22 00:06:42 · 155 阅读 · 0 评论