Linear time selection
problem
The general formulation of the element selection problem is: given n elements and an integer k in the linear order set, 1 < = k < = n, it is required to find the K smallest element in the n elements.
solution
Random time linear selection
In the textbook "algorithm design and analysis (Third Edition)" (Wang Xiaodong), ...
Posted by Richardtagger on Mon, 28 Mar 2022 01:55:45 +0300
Blue Bridge Cup - a province of violence
1.
Title Description
There is an \ n \times mn × m the chessboard of the square, find out how many squares and rectangles the square contains (excluding squares).
Input format
One line, two positive integers n,mn,m (n \leq 5000,m \leq 5000n ≤ 5000,m ≤ 5000).
Output format
One line, two positive integers, respectively indicat ...
Posted by voitek on Sat, 26 Mar 2022 17:10:01 +0300
Sword finger Offer II 116 Number of provinces / circle of friends (medium map bfs and search Collection)
Sword finger Offer II 116 Number of provinces
There are n cities, some of which are connected to each other, others are not connected. If city a is directly connected to city b and city b is directly connected to City c, city a is indirectly connected to city c.
A province is a group of directly or indirectly connected cities, excluding other ...
Posted by tomwhalen on Sat, 26 Mar 2022 15:49:13 +0300
D14 acwing code implementation 3.2-4.1 + review
Recently, I feel really mature and happy~ Uh huh~ Study~ I didn't go to bed until 3 last night and got up at 6:30 in the morning But it doesn't matter. I love life and study!!! come on.
Today, let's implement the code first. If you're tired of implementation, go to review the previous. You'd better watch two more lessons DP hey ~ come on!!!
& ...
Posted by recset on Sat, 26 Mar 2022 15:41:34 +0300
Leetcode2207. The maximum number of substrings in a string (medium)
catalogue
1. Title Description
2. Naive Approach enumeration traversal
3. Optimized implementation
1. Title Description
Give you a string , text , with a subscript starting from , and another string , pattern with a subscript starting from , 0 , with a length of , 2 , both of which contain only lowercase English letters.
You ...
Posted by godster on Sat, 26 Mar 2022 13:51:03 +0300
114. Expand the binary tree into a linked list
114. Expand the binary tree into a linked list
Difficulty: medium
Here is the root node of the binary tree. Please expand it into a single linked list:
The expanded single linked list should also use TreeNode, where the right sub pointer points to the next node in the linked list, and the left sub pointer is always null.The expanded single l ...
Posted by Roo on Sat, 26 Mar 2022 12:28:59 +0300
Brush questions every day -- leetcode sword finger offer 3, 4, 5, 29, 50
Start preparing to find a job, target java development, learn java from 0, and update the experience of brushing questions every day. Today, there are several basic arrays and matrices.
Duplicate number in sword finger offer3 array
All numbers in an array of length n are in the range of 0 to n-1. Some numbers in the array are repeated, but I ...
Posted by SFDonovan on Sat, 26 Mar 2022 02:38:15 +0300