leetcode meituan real exercise 03
meituan-005. Xiaomei's Regional Conference
Title Description
Xiaomei is an executive of meituan headquarters. She wants to call some regional heads of meituan for a meeting. It is known that meituan's business area division can be represented by a tree. There are n nodes on the tree, each node represents a business area of meituan, and ea ...
Posted by Bogart on Mon, 20 Dec 2021 06:19:05 +0100
111 minimum depth of binary tree
subject
Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes on the shortest path from the root node to the nearest leaf node.
Note: leaf nodes refer to nodes without child nodes.
Example 1: Input: root = [3,9,20,null,null,15,7] Output: 2
Example 2: Input: root = [2,null,3,null,4,null,5,null,6] Output: 5
M ...
Posted by Bomas on Sun, 19 Dec 2021 19:47:43 +0100
Quick merge insert sort of single linked list
catalogue
Insert sort
Quick sort
Merge sort
Bubble sorting
Insert sort
Corresponding letecode link:
Force buckle
Title Description:
To give you the head node of the linked list, please arrange it in ascending order and return the sorted linked list.
Advanced:
Can you sort the linked list under O(n log n) time complexit ...
Posted by JJ123 on Sun, 19 Dec 2021 11:51:53 +0100
LeetCode interview hot question 6
101. Symmetric binary tree
Given a binary tree, check whether it is mirror symmetric. For example, a binary tree [1,2,2,3,4,4,3] is symmetric.
1
/ \
2 2
/ \ / \
3 4 4 3
Method 1: recursion Problem solving idea: recurse the left and right subtrees and judge whether they are equal.
public boolean isSymmetric(TreeNode root) ...
Posted by bradkenyon on Sun, 19 Dec 2021 11:10:20 +0100
LeetCode 112. Path sum [c++/java detailed problem solution]
1. Title
Give you the root node root of the binary tree and an integer targetSum representing the target sum. Judge whether there is a path from the root node to the leaf node in the tree. The sum of all node values on this path is equal to the target and targetSum.
A leaf node is a node that has no children.
Example 1:
Input: root = ...
Posted by harman on Sun, 19 Dec 2021 07:36:00 +0100
[JAVA] detailed explanation of data insertion algorithm of binary tree
Example: leetcode question 701 Binary tree insert data Title: Given the root node of the binary search tree (BST) and the value to be inserted into the tree, insert the value into the binary search tree. Returns the root node of the inserted binary search tree. The input data ensures that the new value is different from any node value in the or ...
Posted by Avi on Sun, 19 Dec 2021 02:19:01 +0100
leetcode 12 interesting topics in life
121. The best time to buy and sell stocks [logic]
Given an array of prices, its ith element prices[i] represents the price of a given stock on day I.
You can only choose to buy this stock one day and sell it on a different day in the future. Design an algorithm to calculate the maximum profit you can make.
Return the maximum profit you c ...
Posted by jotgabbi on Sat, 18 Dec 2021 23:17:33 +0100
Longest substring without duplicate characters -- using hash set
The solution refers to the official solution on leetcode.
class Solution { public int lengthOfLongestSubstring(String s) { / / a hash collection that records whether each character has occurred Set<Character> occ = new HashSet<Character>(); int n = s.length(); / / the right pointer, whose initial value is - 1 ...
Posted by stanleybb on Sat, 18 Dec 2021 14:57:54 +0100
Topic summary of recursive backtracking (issue 4)
Directions for the first three phases:
Phase I
Phase II
Phase III
This should be the last issue of backtracking. The previous topics are more conventional, basically what subset or arrangement of written language. This issue summarizes some topics that prefer application. Of course, the essence is still that set.
Examples
Letter combinati ...
Posted by nmal on Sat, 18 Dec 2021 10:38:07 +0100
[illustration LeetCode 707] learn five operations of linked list.
Hello, everyone. I'm an egg.
Today, let's design the linked list and forcibly learn the five operations of the linked list.
Set the bench and open it directly.
LeetCode 707: Design linked list
meaning of the title
Realize the search, header insertion, tail insertion, general insertion and deletion of linked list:
get(index): get the v ...
Posted by feliperal on Sat, 18 Dec 2021 06:54:22 +0100