[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "next arrangement"
1, Title Requirements
An arrangement of an integer array is to arrange all its members in sequence or linear order.For example, arr = [1,2,3], the following can be regarded as the arrangement of arr: [1,2,3], [1,3,2], [3,1,2], [2,3,1].The next permutation of an array of integers refers to the next lexicographically ordered permutation of its i ...
Posted by vboyz on Thu, 27 Jan 2022 07:32:00 +0100
[Leetcode]2045. The second short time to reach the destination
Title Description
Cities are represented by a two-way connected graph, in which there are n nodes, numbered from 1 to n (including 1 and N). The edges in the figure are represented by a two-dimensional integer array edges, where each
e
d
g
...
Posted by iijb on Wed, 26 Jan 2022 22:32:53 +0100
Constructing binary tree from traversal sequence
Constructing binary tree from pre / mid / post traversal sequence
Basics
First of all, we need to know the specific order of the three depth first traversal binary trees:
Preface: middle left and rightMiddle order: left middle rightPost order: left and right middle
In addition, you should know that only middle order + pre / post order can u ...
Posted by hd_webdev on Wed, 26 Jan 2022 20:50:40 +0100
Summary of dynamic programming of leetcode 1(Java)
Summary of leetcode dynamic programming 1
1-longest palindrome substring Title Link: Title Link stamp here!!! The test passed several times. The AC code is as follows. The first use of violence enumeration, double pointer to judge palindromes, timeout. The second time, I thought it was OK to flip the string and compare it with the original st ...
Posted by lucym on Wed, 26 Jan 2022 19:23:27 +0100
Sword finger offer45: arrange the array into the smallest number
A string or says it's a math problem
1. Violence
Ah, at first glance, we will think that if we find out the full arrangement of strings and then sort to select the smallest, but this is O(n!) Time complexity, I'm afraid this has to explode
2. Mathematical proof + sorting
First of all, both the book and the solution give a definition, ...
Posted by rahish on Wed, 26 Jan 2022 18:53:41 +0100
Brush questions every day Day13
Question 1: the next larger element I The next larger element of the number x in nums1 refers to the first element larger than x to the right of the corresponding position of X in nums2. Give you two arrays nums1 and nums2 without duplicate elements. The subscript counts from 0, where nums1 is a subset of nums2. For each 0 < = I < nums1 L ...
Posted by sniped22 on Wed, 26 Jan 2022 03:03:15 +0100
LeetCode sword finger Offer II retrospective summary
๐ Blog home page: โญ This is a little Yibai blog duck~ โญ ๏ธ๐ Welcome to pay attention โค๏ธ give the thumbs-up ๐ Collection โญ Comments ๐๐ Xiaoyibai is preparing for his internship. He often updates the interview questions and LeetCode solutions. Friends with similar interests are welcome to communicate with each other~ ๐ If you have any ...
Posted by Loryman on Wed, 26 Jan 2022 00:21:48 +0100
Force buckle - Sword finger Offer II 111 Calculate division (Figure + BFS)
Given a variable pair array equations and a real value array values as known conditions, where equations[i] = [Ai, Bi] and values[i] jointly represent the equation Ai / Bi = values[i]. Each Ai or Bi is a string representing a single variable.
There are also some problems represented by array queries, where queries[j] = [Cj, Dj] represents the ...
Posted by Joe689 on Tue, 25 Jan 2022 21:57:16 +0100
Weekly leetcode - NC13/NC70/NC62/NC73/NC112/NC96/NC34/62/NC57/7/NC16/NC25/237/82/NC9/NC55
simple
Niuke Tiba - NC13 maximum depth of binary tree
Find the maximum depth of a given binary tree. Depth refers to the number of nodes on the path from the root node of the tree to any leaf node. The maximum depth is the maximum depth of all leaf nodes.
public class Solution {
public int maxDepth (TreeNode root) {
if(root== ...
Posted by tarlejh on Tue, 25 Jan 2022 18:37:53 +0100
[Capriccio 10 Fan Wai] prefix and array
Prefix and array
Learn from Small and beautiful algorithm skills: prefix and array
303. Region and retrieval - array immutable 304. Two dimensional area and retrieval - the matrix is immutable 560. Subarray with sum K 1314. Matrix areas and
The key to distinguish between prefix and sliding window is whether the element has a negative number ...
Posted by Malkavbug on Tue, 25 Jan 2022 14:54:21 +0100