后缀数组(Suffix Array)

本文介绍后缀数组的定义与构建的过程。首先,文章介绍什么是后缀数组,随后讲解了最自然的朴素算法。为了引出更高效的算法,文章提及了倍增思想与基数排序的背景基础知识。接着,通过模拟演练的方式一步一步地演示如何创建后缀数组。将构建的抽象过程形象地展示出来,使读者更易理解。定义给定字符串,其所有后缀有。(6为字符串的长度)。如下所示S = "banana"s1 = "banana"s2 = "anana"s3 = "nana"s4 = "ana"s5 = "na"s6 = "a"后缀数组即为由构成的有序的(字典序升序排列的)字符串数组。vector<string> sa{"a", "ana", "anana", "banana", "na", "nana"};构建后缀数组的动态过程演示动画: https://visualgo.net/zh/suffixarra思路如何构建后缀数组?若字符串的长... Read More

《DATA STRUCTRUES A Psuedocode Approach with C++》Chaper 3. Linked List Learn Note

3-1 LINEAR LIST CONCEPTLinear lists can be divided into two categories: general and restricted.In a general list, data can be inserted and deleted anywhere and there are no restrictions on the operations that can be used to process the list. Such as the randomlist, orderedlist.In a restrictedlist, data can only be added or deleted at the ends of the structure and processing is restricted to opera... Read More

LeetCode OJ Algorithm – Sliding Window Maximum(hard)

原题Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.For exampleGiven nums = [1,3,-1,-3,5,3,6,7], and k = 3.Window position Ma--------------- ----[1 3 -1] -3 5 3 6 7 1 [3 -1 -3]... Read More

LeetCode OJ Algorithm – reverse linked list ii (medium)

原题Reverse a linked list from position m to n. Do it in-place and in one-pass.For exampleGiven 1->2->3->4->5->NULL, m = 2 and n = 4return 1->4->3-&gNoteGiven m, n satisfy the following condition1 ≤ m ≤ n ≤ length of list.地址https://leetcode.com/problems/reverse-linked-list-ii程序范例[code lang="cpp"/** Definition for singly-linked list.* struct ListNode * int val;* ListNode *next;* ... Read More