原题链接:https://leetcode-cn.com/problems/linked-list-cycle/

快慢指针

bool hasCycle(ListNode *head) {ListNode *p = head, *q =head;while (q && q->next) {p = p->next;q = q->next->next;if (p == q) return true;}return false;
}

leetcode算法题--环形链表相关推荐

  1. leetcode算法题--环形链表 II★

    原题链接:https://leetcode-cn.com/problems/linked-list-cycle-ii/ 1.map ListNode *detectCycle(ListNode *he ...

  2. leetcode算法题--相交链表

    原题链接: https://leetcode-cn.com/problems/intersection-of-two-linked-lists/ https://leetcode-cn.com/pro ...

  3. leetcode算法题--分隔链表

    原题链接:https://leetcode-cn.com/problems/split-linked-list-in-parts/ vector<ListNode*> splitListT ...

  4. leetcode算法题--排序链表★

    原题链接:https://leetcode-cn.com/problems/sort-list/ 1.归并排序(递归版) ListNode* sortList(ListNode* head) {if( ...

  5. leetcode算法题--重排链表★

    原题链接:https://leetcode-cn.com/problems/reorder-list/ 1.map void reorderList(ListNode* head) {map<i ...

  6. leetcode算法题--有序链表转换二叉搜索树★

    原题链接:https://leetcode-cn.com/problems/convert-sorted-list-to-binary-search-tree/ 1.二分法+递归 TreeNode* ...

  7. leetcode算法题--反转链表 II★

    原题链接:https://leetcode-cn.com/problems/reverse-linked-list-ii/ 1.头插法 ListNode* reverseBetween(ListNod ...

  8. leetcode算法题--分隔链表★

    原题链接:https://leetcode-cn.com/problems/partition-list/ 1.双指针 ListNode* partition(ListNode* head, int ...

  9. leetcode算法题--旋转链表

    原题链接:https://leetcode-cn.com/problems/rotate-list/ 1.双指针法 相关题目:删除链表的倒数第N个节点 ListNode* rotateRight(Li ...

最新文章

  1. mysql和java区别_java和mysql的length()区别及char_length()
  2. SharePoint 2010 与 SQL Server 2012 报表服务集成
  3. Objective-C:GCC+GNUstep配置
  4. 不合法的偏移量 钉钉接口_钉钉服务端api接口使用
  5. ASCII码与string的相互转换
  6. System.out.println(i++); System.out.println(++i);的区别
  7. 阶级斗争的作用_21世纪的阶级斗争
  8. oracle中使用impdp数据泵导入数据提示“ORA-31684:对象类型已经存在”错误的解决......
  9. 网课答题查询助手 内置多个接口
  10. Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands
  11. java实现猜测游戏,最后统计用户猜的次数
  12. Android -- RecyclerView实现顶部吸附效果
  13. 12星座超级独家!通过星座完美你自己!不断加新中……
  14. storm trident mysql_Trident-MySQL
  15. ts(TypeScript)定义服务器返回数据类型
  16. PC时代结束 Web取而代之
  17. 使用Speech Synthesis API 做语音播放
  18. 地图经纬度纠偏-所有高德系地图纠偏
  19. 一文搞定!!!多智能体强化学习的前世今生
  20. 【spark】本地开发关闭日志打印

热门文章

  1. python介绍和用途-Python对象与引用的介绍
  2. python三层装饰器-python三大神器===》装饰器
  3. python 打开文件-Python 读文件
  4. 北京理工大学 python专题课程-Python第七章(北理国家精品课 嵩天等)
  5. python有什么作用-Python中的闭包到底有什么用
  6. 学python好不好-学习python的前景怎么样?
  7. python上海培训哪里比较好-上海哪个python培训机构好
  8. tc-auth-lib学习笔记
  9. LeetCode Arithmetic Slices(动态规划)
  10. 题目1255:骰子点数概率(动态规划)