• leetcode 769. Max Chunks To Make Sorted

Time：2022-12-7

1. The main idea of ​​the topic Tags: array https://leetcode.cn/problems/max-chunks-to-make-sorted Given an integer array arr of length n, which represents the permutation of integers in the range [0, n – 1]. We split arr into chunks (ie partitions) and sort each chunk individually. After concatenating them, the result of the concatenation is the same as […]

• leetcode 232. Implement Queue using Stacks implement queue with stack (simple)

Time：2022-12-6

1. The main idea of ​​the topic Tags: stacks and queues https://leetcode.cn/problems/implement-queue-using-stacks Please use only two stacks to implement a first-in-first-out queue. The queue should support all operations supported by general queues (push, pop, peek, empty): Implement the MyQueue class: void push(int x) pushes element x to the end of the queueint pop() removes and […]

• leetcode 155. Min Stack minimum stack (medium)

Time：2022-12-5

1. The main idea of ​​the topic Tags: stacks and queues https://leetcode.cn/problems/min-stack Design a stack that supports push, pop, top operations, and can retrieve the smallest element in constant time. Implement the MinStack class: MinStack() // Initialize the stack object. void push(int val) // Push the element val onto the stack. void pop() // Remove […]

• leetcode 20. Valid Parentheses valid parentheses (medium)

Time：2022-12-3

1. The main idea of ​​the topic Tags: stacks and queues https://leetcode.cn/problems/valid-parentheses Given a string s consisting only of ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘, ‘]’, determine whether the string is valid. A valid string must satisfy: An opening parenthesis must be closed with a closing parenthesis of the same type.Opening parentheses must be closed in […]

• leetcode 739. Daily Temperatures Daily temperature (medium)

Time：2022-12-2

1. The main idea of ​​the topic Tags: stacks and queues https://leetcode.cn/problems/daily-temperatures Given an integer array temperatures representing daily temperatures, return an array answer , where answer[i] means that for the i-th day, the next higher temperature will appear in a few days. If the temperature doesn’t rise after that, use 0 in that place […]

• leetcode 23. Merge k Sorted Lists Merge K ascending linked lists (difficult)

Time：2022-12-1

1. The main idea of ​​the topic Tags: stacks and queues https://leetcode.cn/problems/… You are given an array of linked lists, each already sorted in ascending order. Please merge all linked lists into an ascending linked list, and return the merged linked list.   Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]]Output: [1,1,2,3,4,4,5,6]Explanation: The linked list array is […]

• leetcode 239. Sliding Window Maximum

Time：2022-11-30

239. Sliding Window Maximum Maximum sliding window 1. The main idea of ​​the topic Tags: deque https://leetcode.cn/problems/… You are given an integer array nums with a sliding window of size k moving from the leftmost of the array to the rightmost of the array. You can only see k numbers within the sliding window. The […]

• leetcode 128. Longest Consecutive Sequence The longest continuous sequence (medium)

Time：2022-11-28

1. The main idea of ​​the topic https://leetcode.cn/problems/longest-consecutive-sequence Given an unsorted integer array nums, find the length of the longest sequence of consecutive numbers (it is not required that the elements of the sequence are consecutive in the original array). Please design and implement an algorithm with time complexity O(n) to solve this problem. Example […]

• leetcode 303. Range Sum Query – Immutable area and retrieval – array immutable (simple)

Time：2022-11-27

1. The main idea of ​​the topic https://leetcode.cn/problems/range-sum-query-immutable Given an integer array nums, handle multiple queries of the following types: Computes the sum of nums elements between indices left and right (inclusive), where left <= rightImplement the NumArray class: NumArray(int[] nums) Initialize the object using the array numsint sumRange(int i, int j) Returns the sum […]

• leetcode 304. Range Sum Query 2D – Immutable two-dimensional area and retrieval – matrix immutable (medium)

Time：2022-11-26

1. The main idea of ​​the topic https://leetcode.cn/problems/… Given a two-dimensional matrix matrix, multiple requests of the following types: Computes the sum of the elements within its subrectangle, which has (row1, col1) in its upper left corner and (row2, col2) in its lower right corner.Implement the NumMatrix class: NumMatrix(int[][] matrix) Initialize given integer matrix matrixint […]

• leetcode 225. Implement Stack using Queues implement stack with queue (simple)

Time：2022-11-25

1. The main idea of ​​the topic Please use only two queues to implement a last-in-first-out (LIFO) stack, and support all four operations (push, top, pop, and empty) of a normal stack. Implement the MyStack class: void push(int x) pushes the element x onto the top of the stack.int pop() removes and returns the top […]

• leetcode 560. Subarray Sum Equals K and the subarray of K (medium)

Time：2022-11-23

1. The main idea of ​​the topic https://leetcode.cn/problems/… Given an integer array nums and an integer k, please count and return the number of continuous subarrays whose sum is k in this array. Example 1: Input: nums = [1,1,1], k = 2Output: 2 Example 2: Input: nums = [1,2,3], k = 3Output: 2 hint: 1 […]