Heap related issues

We talked last time Heap and heap sorting This time, let's talk about heap related topics.1, Almost ordered array sorting1. Title DescriptionAn almost ordered array is known, which means that if the array is arranged in order, the distance of each element must not exceed K, and K is relatively small relative to the length of the array.Please se ...

Posted by narked on Mon, 06 Dec 2021 15:04:08 -0800

Analysis of leetcode problem solving ideas (100) 860 - 866 questions

Lemonade change At the lemonade stand, each glass of lemonade costs $5. Customers line up to buy your products (in the order of bill payment) one cup at a time. Each customer buys only one glass of lemonade and pays you $5, $10 or $20. You must give each customer the correct change, that is, the net transaction is that each customer pays you $5 ...

Posted by modcar on Mon, 06 Dec 2021 14:36:55 -0800

Leetcode.1005. Maximized array sum after K negations - greedy + count sorting

12.6 one question per day - maximum array sum after K inversions Enter an array of integers and an integer k to modify the array as follows 1. Select a subscript i and replace num [i] with - num [i] 2. Repeat this process exactly k times. You can select the same subscript i multiple times. When the array is modified in this way, the maximum po ...

Posted by nicholasstephan on Mon, 06 Dec 2021 13:03:44 -0800

Algorithm notes - Basic Algorithms

Quick sort Algorithm idea: select a number in the array x x x. Make all > = x >=x >=The number of X is on the right, ...

Posted by yellowzm on Mon, 06 Dec 2021 11:37:59 -0800

Array Iterator Method

This counting method is primarily used to iterate over array objects, which in turn pass each element of the array to the functions we provide to facilitate iteration, mapping, filtering, testing, and merging of the array. Before talking about these methods, let's first understand that all of them accept a function as their first argument and ...

Posted by arnoldd99 on Mon, 06 Dec 2021 09:50:13 -0800

[LeetCode] 2095. Delete the Middle Node of a Linked List as the intermediate node of the chain list

Author: Ming Xue Candleid: fuxuemingzhuPersonal blog: http://fuxuemingzhu.cn/Public number: snowy candlesKey words in this article: Leetcode, buckle, brush title, Python, C++, chain list, intermediate node, delete Title Address: https://leetcode-cn.com/problems/delete-the-middle-node-of-a-linked-list/ Title Description Give you the he ...

Posted by Shendemiar on Mon, 06 Dec 2021 09:36:46 -0800

Principle of distributed algorithm

Common generation strategies of distributed ID The common distributed ID generation strategies are as follows: Database autoincrement ID.UUID generation.Redis's atomic self increasing mode.Split the database horizontally, and set the initial value and the same self increasing step size.Self increment ID for batch application.Snowflake algorit ...

Posted by formlesstree4 on Sun, 05 Dec 2021 21:39:01 -0800

Some thoughts on single objective swarm intelligence algorithm

      Since the development of computer algorithms, there have been many different classifications. At present, the most widely used is the generalized swarm intelligent optimization algorithm. For example, particle swarm optimization (PSO), whale optimization (WOA), gray wolf optimization (GWO), dragonfly optimization (DA), uni ...

Posted by teejayuu on Sun, 05 Dec 2021 18:24:48 -0800

Heap and heap sorting

Hello, I'm Monday. Today we talk about heap and heap sorting.1, PileWhen it comes to heaps, we should first start with binary trees, from binary trees to complete binary trees, and then to heaps.1. Binary treeEach node can only have two subtrees at most, and can be divided into left and right2. Complete binary treeFor a binary tree with n node ...

Posted by Rizla on Sun, 05 Dec 2021 16:02:42 -0800

Dijkstra algorithm details (single source shortest path algorithm)

Most of us may know BFS and DFS better. For Dijkstra algorithm, it is the algorithm to solve the single source shortest path problem in the graph algorithm structure. It is probably such a weighted graph. Dijkstra algorithm can calculate the shortest path from any node to other nodes. (single source shortest path problem), Dijkstra algorithm c ...

Posted by hayson1991 on Sun, 05 Dec 2021 12:37:44 -0800