摘要:
//思路:回溯法(先序遍历+路径记录) //关于回溯法的模板网上很多,大家可以去查一下 class Solution { LinkedList<List<Integer>> res = new LinkedList<>(); LinkedList<Integer> path = new Linked 阅读全文
posted @ 2021-03-10 17:58
ForMei
阅读(57)
评论(0)
推荐(0)
摘要:
//给定一个链表判断是否有环 //思路:快慢指针和HashSet都可以做,前者可以有O(1)较小的空间复杂度,后者至少是O(n) //给出最优的做法 public class Solution{ public boolean hasCycle(ListNode head){ if(head==nul 阅读全文
posted @ 2021-03-10 14:21
ForMei
阅读(49)
评论(0)
推荐(0)

浙公网安备 33010602011771号