随笔分类 - LeetCode
摘要:KMP算法 KMP算法是一种改进的字符串匹配算法,由D.E.Knuth、J.H.Morris和V.R.Pratt提出的(简称KMP算法)。 KMP算法的核心是利用匹配失败后的信息,尽量减少模式串与主串的匹配次数以达到快速匹配的目的。具体实现就是通过一个next()函数实现,函数本身包含了模式串的局部
阅读全文
摘要:141. 环形链表 Leetcode: https://leetcode cn.com/problems/linked list cycle/ 给定一个链表,判断链表中是否有环。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 1
阅读全文
摘要:一、题目要求 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes
阅读全文
摘要:一、题目要求 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would
阅读全文

浙公网安备 33010602011771号