Classic example of sliding window (maximum and minimum)

Simple concept of sliding window Sliding window is a hypothetical data structure. The window we implement in this article can quickly find the maximum and minimum value of the interval The operation efficiency is also excellent in some problems that do not go back in the interval Set the left boundary of the window as l and the right boundar ...

Added by parboy on Wed, 23 Feb 2022 17:27:24 +0200

leetcode basic programming: linked list

148. Remove linked list elements Difficulty: simple Collection Give you a head node of the linked list and an integer val. please delete all nodes in the linked list that meet the requirements Val = = Val node and returns a new header node. Example 1: Input: head = [1,2,6,3,4,5,6], val = 6 Output: [1,2,3,4,5] Example 2: Input: head = [], va ...

Added by vronsky on Wed, 23 Feb 2022 12:48:47 +0200

Algorithm - stack and queue (Java implementation)

Stacks and queues and priority queues 1. Push in and pop-up sequence of stack Enter two integer sequences. The first sequence represents the push in order of the stack. Please judge whether the second sequence may be the pop-up order of the stack. Assume that all the numbers pushed into the stack are not equal. For example, sequence 1,2,3 ...

Added by KGodwin on Tue, 22 Feb 2022 17:30:41 +0200

[golang] leetcode intermediate - Change Exchange & longest rising subsequence

Question 1 ChangesubjectGreedy (invalid)In daily life, if we want to exchange change, the most simple thinking is naturallyIf a coin with a larger denomination can be used, it is preferredThis is the thinking of greedy algorithmcodefunc coinChange(coins []int, amount int) int { var res int sort.Ints(coins) if amount==0{return 0} ...

Added by unreal128 on Tue, 22 Feb 2022 14:20:05 +0200

[LeetCode notes] binary search special

Binary search = half search Time complexity O (logN) The most standard search Initialize left boundary int len = arr.length - 1; int l = 0; int r = len-1; while loop judgment condition This is a left closed right closed interval (I often use it) while (left <= right) There are also left closed and right open (not commonly used) ...

Added by jimmy2gurpreet on Tue, 22 Feb 2022 13:34:15 +0200

STL topology sorting

preface My story with topological sorting The first contact was the class of data structure. However, I was addicted to playing games and didn't understand the code at that time. The second time was the punch in group. The second question of a force deduction fortnightly competition was topological sorting (I used violence to cycle 100 times ...

Added by hi2you on Tue, 22 Feb 2022 07:53:43 +0200

[leetcode question brushing day 39] 969 Pancake sorting, 1104 Binary tree pathfinding, 838 Push domino, 717 1-bit and 2-bit characters

Day 39 969 pancake sorting Give you an integer array arr, please use pancake flip to sort the array. The execution process of a pancake flip is as follows: Select an integer k, 1 < = k < = arr.length Inverse rotor array arr[0...k-1] (subscript starts from 0) For example, arr = [3,2,1,4], select k = 3 to flip the pancake once, reve ...

Added by meshi on Mon, 21 Feb 2022 18:12:41 +0200

Binary tree topic 03

Question 1: Question 617 of force deduction Problem solving ideas: reference This article The code is as follows: class Solution { public TreeNode mergeTrees(TreeNode root1, TreeNode root2) { if(root1 == null) { return root2; } if(root2 == null) { return root1; } TreeNode r ...

Added by guiltyspark on Mon, 21 Feb 2022 14:35:22 +0200

keepMoving binary tree sequence traversal deformation and minimum dictionary ordered substring with length k

Let's start with sequence traversal. This is a common problem. Print it according to each layer, as follows: For Recommendation in Deep learning QQ Group 277356808 For deep learning QQ Second Group 629530787 I'm here waiting for you 1 - sequence traversal and deformation Sequence traversal is the most intuitive and simplest sequence, that ...

Added by kelvin on Mon, 21 Feb 2022 11:44:53 +0200

[Leetcode notes] monotonous stack

I have encountered a lot of monotonous stack problems when I brush questions recently. I hereby record it. I forget it all in the future. The monotone stack problem has a feature that most of the stack does not store elements directly, but subscripts, which are used to judge. Monotone stack, as the name suggests, means that the elements stored ...

Added by FijiSmithy on Sun, 20 Feb 2022 20:48:22 +0200