LeetCode notes (algorithm idea 5)
8, Mathematics
204. Count prime
Count the number of all prime numbers less than non negative integer n.
Example:
input: 10
output: 4
explain: There are four prime numbers less than 10, They are two, 3, 5, 7 .
Idea: this problem needs to consider optimization in order to make the algorithm efficient. Using the eratoseni sieve method ...
Added by PeterPopper on Mon, 07 Mar 2022 22:55:00 +0200
I'll practice the algorithm with you (hash + linked list + double pointer)
hash
1. Sum of two numbers
The idea is to save it in the hash table first, and then judge whether it exists again. Use target -
class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer,Integer> map = new HashMap<>();
for(int i = 0;i < nums.length;i++){
if(map. ...
Added by Jaguar on Mon, 07 Mar 2022 22:14:05 +0200
Why is the collection tool class of Java so popular (go deep into Comparable, Comparator, Collections and Arrays from the perspective of algorithm)
1: Foreword
friends who have studied Java must have used the four Java collection tools: Comparable, Comparator, Collections and Arrays. I just want to ask you, do these four tools smell good? Very fragrant, ha ha ha. In my opinion, the better the interface tools are used, the less simple the underlying principle implementation will be ...
Added by ColinP on Mon, 07 Mar 2022 21:21:14 +0200
[daily question brushing 3.7] 10 algorithms + 10 interviews - ah V
In the new week, come on ~, make progress a little every day ~.
Algorithm problem (Niuke network)
1. Fibonacci sequence
The Fibonacci sequence starts with the third term and is equal to the sum of the first two terms.
Code details:
class Solution {
public:
int Fibonacci(int n) {
vector<int> dp(n + 1);
dp[ ...
Added by Ice on Mon, 07 Mar 2022 18:07:16 +0200
IO stream principle and stream classification basic introduction to FileInputStream class and FileOutputStream class
IO stream principle and stream classification
How java IO streams work
I/O is the abbreviation of Input stream / Output stream. I/O technology is a very practical technology for processing data transmission. Such as reading and writing files, network communication, etc.In Java program, the input / output operation of data is carried out in th ...
Added by mnuzum on Mon, 07 Mar 2022 14:54:55 +0200
2022-03-07 swipe questions and punch in every day
1, Informatics OJ: 1275: [example 9.19] maximum product
(1) Title Description
This year is the "2000 - world year of mathematics" determined by the International Mathematical Union, and coincides with the 90th anniversary of the birth of Mr. Hua Luogeng, a famous mathematician in China. In Jintan, Jiangsu, Mr. Hua Luoge ...
Added by ThatGuyBob on Mon, 07 Mar 2022 14:36:31 +0200
Programming topic + database topic summary
Programming problem
prices = {
'AAPL': 191.88,
'GOOG': 1186.96,
'IBM': 149.24,
'ORCL': 48.44,
'ACN': 166.89,
'FB': 208.09,
'SYMC': 21.29
}
1. Some stock codes (keys) and prices (values) are saved in the dictionary. Use one line of code to find the stock with the highest price and output the stock code. (5 poin ...
Added by gregtel on Mon, 07 Mar 2022 14:20:06 +0200
The 12th Blue Bridge Cup Java group B provincial competition (title and AC Title Solution)
Question 1: ASCII code
[problem description] It is known that the ASCII code of capital letter A is 65. What is the ASCII code of capital letter L? [answer submission] This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is one An integer. Only fill in this intege ...
Added by JaGeK on Mon, 07 Mar 2022 13:48:18 +0200
Monotone queue optimization for multiple knapsack problems
Monotone queue optimization for multiple knapsack problems
Warm tips: it's better to eat dessert first and then enter the dinner~
0-1 backpack problem (dessert)
https://www.acwing.com/problem/content/2/
Simple solution
#include <iostream>
using namespace std;
const int N = 1010;
int n, m; //n number of items m maximum capacit ...
Added by hardyvoje on Mon, 07 Mar 2022 12:37:59 +0200
Spring boot uses spring's built-in scheduled tasks
Original link
https://cloud.tencent.com/developer/article/1582434
1. Preface
We often use timed tasks in daily project development. For example, make statistics and settlement in the early morning, start planning activities, automatically change the unpaid orders that exceed 24 hours to cancelled status, and automatically change the orde ...
Added by danoli on Mon, 07 Mar 2022 10:51:20 +0200