Tag：Complexity

Time：202135
The first question of new year’s brush is as follows: Give you a string s and find the longest palindrome substring in S. Example 1: Enter: S = “bad”Output: “bab”Explanation: “ABA” is also the answer to the question.Example 2: Enter: S = “CBBD”Output: “BB”Example 3: Input: S = “a”Output: “a”Example 4: Enter: S = […]

Time：202135
Binary search tree concept Binary search tree, also known as binary search tree, binary sort tree, has the following characteristics: The values of all nodes in the left subtree are less than the root nodes All nodes in the right subtree are larger than the root The left and right subtree of the node itself […]

Time：202134
Perception: Taste: ants on the tree Cooking time: 10min This article has been included inGithub github.com/GeekhytThank you, star. Mr. Zhou Shuren once said: if you learn tree well, you will master half of data structure and algorithm! Canteen owner (Tong oba): even if we are the leaf nodes in the Internet wave, we also need […]

Time：202134
The longest ascending subsequence is a classical algorithm problem. Some will ask you to find the longest ascending subsequence directly, others will put it another way, but the final investigation is the longest ascending subsequence. So the problem is, you can still see it in clothes, can’t you? If you can’t see it at all, […]

Time：2021226
The use of double pointer in the algorithm sometimes feels very clever and solves a lot of problems. It is necessary to sum up. First of all, double pointer is a very broad concept, which is similar to traversalI and jBut the difference is that the two pointers move at the same time, that is, […]

Time：2021226
34. Find the first and last positions of the elements in the sorted array Title Source: leetcode https://leetcodecn.com/problems/findfirstandlastpositionofelementinsortedarray subject Given an integer array nums in ascending order and a target value target. Find out the start and end position of the given target value in the array. Your algorithm time complexity must be o (log […]

Time：2021225
Example: missing first positive number Source: leetcode Link:https://leetcodecn.com/probl… In situ hash Example: Missing first positive number Difficulty: hard describe To give you an unsorted integer array, please find the smallest positive integer that does not appear in it. Examples Example 1: Input: [1,2,0] Output: 3 Example 2: Input: [3, 4, – 1, 1] Output: 2 […]

Time：2021221
209. The smallest subarray Title Source: leetcode https://leetcodecn.com/problems/minimumsizesubarraysum subject Given an array containing n positive integers and a positive integer s, find out the smallest continuous subarray in the array which satisfies the sum ≥ s, and return its length. If there is no qualified continuous subarray, return 0. Example: Input: S = 7, nums […]

Time：2021218
844. Compare strings with backspace Difficulty: simple First: a brief look at the topic Given two strings S and T, when they are respectively input into the blank text editor, judge whether they are equal, and return the result. #Represents a backspace character. be careful:If you enter a backspace character for empty text, the text […]

Time：2021216
stem This question comes from leetcode problem 50. Given x (floating point number) and n (integer), we can find the nth power of X. solution Violent solution Violent solution Of course, take x times N times directly. Note that if n is a negative number, we need to find the reciprocal of X first, and […]

Time：2021216
1： Background 1. Tell a story Yesterday, I saw a very interesting question on stackoverflow, which said: you can traverse the dictionary in several ways, and then follow up with all kinds of wonderful answers. It’s very interesting. The National Day is coming soon. Let’s have fun. Let’s talk about this kind of boring question. […]

Time：2021215
1. Problem: given a string, find out the longest substring without repeating characters The longest unrepeated substring of ABC BC is ABC, and the length of ABC BC is 3 2. Method 1, violence law We can find out each substring, and then find the longest substring without repeating characters. The method is simple […]