随笔分类 -  LeetCode与算法

摘要:1. 数组中无重复元素 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6, 阅读全文
posted @ 2019-07-22 14:05 风影旋新月 阅读(223) 评论(0) 推荐(0) 编辑
摘要:1. KMP算法用途 KMP算法用于解决主字符串和模式字符串匹配的问题。如果完成匹配,返回模式字符串在主字符串匹配的初始索引。如果不匹配,返回-1。 2. PMT(Partial Match Table):部分匹配表(模式字符串) 部分匹配表是KMP算法的核心,定义:前缀集合和后缀集合交集中最长元素 阅读全文
posted @ 2019-07-21 10:41 风影旋新月 阅读(357) 评论(0) 推荐(0) 编辑
摘要:1. 八皇后问题 八皇后问题,是一个古老而著名的问题,是回溯算法的典型案例。该问题是国际西洋棋棋手马克斯·贝瑟尔于1848年提出:在8×8格的国际象棋上摆放八个皇后,使其不能互相攻击,即任意两个皇后都不能处于同一行、同一列或同一斜线上,问有多少种摆法。 思路:使用一个数组gEightQueen存储第 阅读全文
posted @ 2019-07-10 21:06 风影旋新月 阅读(1909) 评论(0) 推荐(0) 编辑
摘要:最坏时间为线性时间的选择算法 目标:返回数组中第k个元素的值,函数名称SELECT 步骤: 1. 将输入数组的n个元素划分成[n/5]组,每组5个元素,且最多只有一组由剩下的n mod 5个元素组成 2. 寻找这[n/5]个元素的中位数,首先对这组元素进行插入排序,然后确定每组有序元素的中位数,即第 阅读全文
posted @ 2019-04-14 14:38 风影旋新月 阅读(290) 评论(0) 推荐(0) 编辑
摘要:题目:翻转整数 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example 3: Note:Assume we are dealing with an environment w 阅读全文
posted @ 2019-03-10 12:15 风影旋新月 阅读(273) 评论(0) 推荐(0) 编辑
摘要:题目:最长的回文串 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: 解答 阅读全文
posted @ 2019-03-10 10:53 风影旋新月 阅读(116) 评论(0) 推荐(0) 编辑
摘要:题目: Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The ans 阅读全文
posted @ 2019-03-07 20:04 风影旋新月 阅读(186) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示