## Algorithm note 11: printing patterns

1. Print diamond pattern
*
* *
* * *
* *
*
#include <stdio.h>
int main()
{
int n = 0;
//Multi group input
while (scanf("%d",&n)!=EOF)
{
//Print top half
//Number of control rows
for (int i = 0; i < n; i++)
{
//Print one line
//Print ...

Posted by **nalleyp23** on *Thu, 04 Nov 2021 17:25:20 +0100*

## Greedy algorithm java

Minimum dictionary order
Given a string type array strs, find a splicing method so that the string formed after splicing all strings has the smallest dictionary order
public class LowestLexicography {
public static class MyComparator implements Comparator<String>{
@Override
public int compare(String o1, Str ...

Posted by **simrx11** on *Thu, 04 Nov 2021 11:13:53 +0100*

## Linked list algorithm and common examples

Linked list
Brief introduction
Hashtable
Hash table can be understood as a collection structure at the use levelIf there is only key and no accompanying data value, you can use the HashSet structure (called unorderderdedset in C + +)If there are both key s and accompanying data value s, you can use the HashMap structure (called unordered ma ...

Posted by **Joan Collins** on *Thu, 04 Nov 2021 06:19:00 +0100*

## Detailed explanation of heap sorting

1, What is a pile?
Heap is actually a binary tree implemented by array. It uses the structure of complete binary tree to maintain a set of data. This makes the time complexity of each group of related operations between O(1)~O(logN), which is quite advantageous.
So what is a complete binary tree? Let's look at this group of pictures: I ...

Posted by **dakey** on *Tue, 02 Nov 2021 12:48:23 +0100*

## Mathematical knowledge I

1, Prime number
Prime number, composite number: all for nature greater than 1. Prime number: contains only two divisors of 1 and itself. 1. Judging prime number (Trial Division) O(sqrt(n)) When enumerating, you only need to enumerate to sqrt(n), because if i is a factor of X, then x/i is also a factor of X.
#include<iostream>
using na ...

Posted by **animedls** on *Sun, 31 Oct 2021 16:52:32 +0100*

## Leetcode 18. Sum of four numbers -- learning notes

Title: Force bucklehttps://leetcode-cn.com/problems/4sum/
class Solution {
public List<List<Integer>> fourSum(int[] nums, int target) {
List<List<Integer>> ans = new ArrayList<>();
Arrays.sort(nums);
int l;
int r;
for(int index1=0;index1<nums.length-3;index1++){
...

Posted by **nafetski** on *Sun, 31 Oct 2021 09:22:06 +0100*

## Data structure course design -- Design of traffic consulting system

1, Problem Description:
Design of traffic consultation system
Design purpose:
Master dijestra algorithm and Floyd algorithm, and be able to use them to solve the shortest path problem.
Master the depth and breadth traversal algorithm of the graph.
Master quick sorting algorithm.
Content:
Design a traffic consulting system by reading Natio ...

Posted by **pranesh** on *Sun, 31 Oct 2021 02:17:02 +0100*

## Design patterns should be learned this way

1. Factory mode
1. Concept
Factory Pattern is one of the most commonly used design patterns in Java. This type of design pattern is a creation pattern, which provides the best way to create objects.
In factory mode, when creating objects, we do not expose the creation logic to the client, and point to the newly created objects by usi ...

Posted by **gunslinger008** on *Sat, 30 Oct 2021 13:23:26 +0200*

## Sorting method enumeration

Sorting method
Stable: after sorting, the positions of numbers of the same size will not be changed
methodthinkingTime complexityIs it stableBubble sortingStart the comparison from the start or end position. If the value is larger or smaller than him, switch and determine a position at a timeO(n2)yesQuick sortAt the beginning, take a number, ...

Posted by **reli4nt** on *Fri, 29 Oct 2021 12:01:21 +0200*

## Heap and heap sorting

The previous blog post roughly described the implementation of priority queue. This one will talk about heap and heap sorting. For priority queue, please refer to the following blog post. Detailed explanation of binary heap and implementation of priority queue
  ...

Posted by **jlryan** on *Fri, 29 Oct 2021 07:11:30 +0200*