2022 winter vacation algorithm summary
1, Introduction to algorithm
1. Simple version
2022-1-11
704. Binary search
Topics and examples Given an n-element ordered (ascending) integer array nums and a target value target, write a function to search the target in nums. If the target value exists, return the subscript, otherwise return - 1.
Example 1: Input: num = [- 1,0,3,5,9,12], ...
Posted by vapour_ on Sun, 27 Feb 2022 11:38:53 +0100
Yesterday's provisional solution
J1001 gcd
Problem solution
KaTeX parse error: Expected 'EOF', got '&' at position 253: ...d(k, t) = 1] &̲ \text{if }t = ...
$\ phi (n) = n * \ prod (1 - \ frac {1} {p_i}) = n * \ prod {\ frac {p_i - 1} {p_i} & [\ text {if} n = \ prod {p_i ^ {a_i}}, p_i \ text {is the quality factor}] \ $
Time complexity:
...
Posted by benjam on Sun, 27 Feb 2022 05:50:36 +0100
[daily algorithm] force deduction 350 Intersection of two arrays II
describe
Given two arrays, write a function to calculate their intersection.
Example 1:
Input: nums1 = [1,2,2,1], nums2 = [2,2]
Output:[2,2]
Example 2:
Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output:[4,9]
explain:
The number of occurrences of each element in the output result shall be consistent with the minimum number of occurrence ...
Posted by phpete2 on Sun, 27 Feb 2022 02:04:52 +0100
Leetcode Brush Title Note - Backpack Problem in Dynamic Planning: 01 Backpack
Catalogue of Series Articles
I. Array Type Solution Method I: Dichotomy 2. Array Type Solution Method 2: Double Pointer Method 3. Array Type Solution Method 3: Sliding Window IV. Array Type Solution Method 4: Simulation V. Basic Operation and Classical Title of Chain List in Chain Table Text 6. Classic Title of Hash Table 7. Classic Title ...
Posted by vbzoom.com on Sat, 26 Feb 2022 18:27:33 +0100
Day02: summary of written test questions
catalogue
1, Multiple choice questions
2, Programming problem
1. Sort subsequence
2. Inverted string
1, Multiple choice questions
1.
Resolution:
Both parent class and new subclass objects are allowed
2.
Resolution:
You can see from the source code of String method tolower case
The return value of this method means that if the ...
Posted by phpwannabe25 on Sat, 26 Feb 2022 13:58:35 +0100
Summary of leetcode's simulated problem brushing 3
Summary of leetcode's simulated problem brushing 3
1-transpose matrix Title Link: Title Link stamp here!!!
Idea: just put the value of the corresponding row in the corresponding column. Do an easy question first to comfort yourself.
class Solution {
public int[][] transpose(int[][] matrix) {
int m = matrix.length ;
int n ...
Posted by Kathy on Fri, 25 Feb 2022 15:05:33 +0100
20220225_ Datawhale 34_ leetcode_7 double pointer
Seven double pointers
1.1 Foundation
Collision pointer: refers to two pointers, left and right, pointing to the first element and the last element of the sequence respectively, and then the left pointer increases and the right decreases until the values of the two pointers Collide (i.e. left == right), or meet other special conditions.
...
Posted by ldougherty on Fri, 25 Feb 2022 09:24:46 +0100
Daily practice LeetCode: M1706 Where does the ball fall
Write in front
Today, I found a very interesting little girl named "BugNotFoundException", which is very interesting. Bug s are an indispensable part of a programmer's life. They spend quite a long time with you, and even you have to lose your hair v_v
Looking at the data, college students have done so many questions. How did I find ...
Posted by yashvant on Fri, 25 Feb 2022 08:40:38 +0100
LeeCode 190. Reverse binary
190. Reverse binary
Simple difficulty
Inverts the binary bits of a given 32-bit unsigned integer.
Tips:
Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be specified as signed integer types and should not affect your implementation, because the internal binary representat ...
Posted by networkguy on Fri, 25 Feb 2022 08:38:30 +0100
Algorithm problem push domino simulation, queue and black magic
Push domino simulation, queue and dark magic
subject
Arrange n dominoes in a row and erect each dominoes vertically. At the beginning, push some dominoes to the left or right at the same time.
Every second, the dominoes that fall to the left push the adjacent dominoes to the left. Similarly, a domino upside down to the right will push th ...
Posted by DavidT on Fri, 25 Feb 2022 05:43:40 +0100