Conceptual understanding of dynamic arrays and the creation and use of one-dimensional and two-dimensional arrays

First define the header file #include<stdio.h> #include<stdlib.h> #include<errno.h> #include<string.h> 1. Allocate memory space function malloc() Call form: (type specifier *) malloc (unsigned int size) Function: Allocate a continuous area with a length of 'size' bytes in the dynamic storage area of memory int *p ...

Posted by new7media on Sat, 20 Nov 2021 20:58:51 +0100

Fluctuation series, simple AC code, detailed explanation.

Wave series This problem really takes time to understand the details. Idea: As shown in the figure below, the first item of the sequence is x, the tolerance is set, set={a, - b}; From the first picture below, we can know that the number of set s is n*(n-1)/2 (formula: first term plus last term divided by 2) We let cnt=n*(n-1)/2 (that is, t ...

Posted by wha??? on Sat, 20 Nov 2021 18:51:25 +0100

[LeetCode question brushing diary] common question types of array questions

This article summarizes the leetcode problem about arrays, and basically finds out the problem-solving ideas and methods of array problems. So that you can quickly find ideas and solutions when you encounter similar problems later. 303. Region and retrieval - array immutable Given an integer array nums, find the sum of the elements in ...

Posted by fiorelina21 on Sat, 20 Nov 2021 01:31:03 +0100

Java collection and underlying source code analysis, introduction to Java zero foundation pdf

If the hash value corresponding to the element at the index position is the same as the hash value of the element to be inserted, and it is the same reference or content, it cannot be added If the index position has a value and satisfies a red black tree, call the algorithm of the red black tree to add If the index position has a value and i ...

Posted by phaseonemedia on Sat, 20 Nov 2021 01:07:23 +0100

Data structure stack expression evaluation

expression Calculation rules From left to right, multiply and divide first, then add and subtract. Brackets count first Constituent elements Add (+), subtract (-), multiply (*), divide (/), parentheses (()), or spaces () Calculation process First convert infix expression into suffix expression, and then evaluate the suffix expression. In th ...

Posted by nakago on Fri, 19 Nov 2021 23:35:12 +0100

Sword finger Offer 09. Queue with two stacks

Sword finger Offer 09. Queue with two stacks Title Description: Implement a queue with two stacks. The declaration of the queue is as follows. Please implement its two functions appendTail and deleteHead to insert integers at the end of the queue and delete integers at the head of the queue respectively. (if there are no elements in the queue, ...

Posted by Mardoxx on Fri, 19 Nov 2021 20:09:11 +0100

Algorithm - classic fun topic - frog crossing the river

This article is an original article of Joshua 317. Please note: reprinted from Joshua 317 blog Algorithm - Classic interesting topics - frog crossing the river - Joshua 317's blog 1, Question Frog crossing the river is a very interesting puzzle game. Its main idea is as follows: There are several stones between a river. There are two teams o ...

Posted by WhiteCube on Fri, 19 Nov 2021 18:03:50 +0100

Modern writing of C++ string

1, Modern writing implementation interface The first is the realization of modern writing method of copy construction: string_str(const string_str& st) :str(nullptr) { string_str tem(st.str); swap(this->str, tem.str); First, set this - > STR to null, then temp calls the constructor and initializes this - > STR wit ...

Posted by Syrehn on Thu, 18 Nov 2021 16:10:22 +0100

[data structure Java version] understand binary search tree

1. Concept Binary search tree (also known as binary sort tree) can be an empty tree or a binary tree with the following properties: If its left subtree is not empty, the value of all nodes on the left subtree is less than the value of the root nodeIf its right subtree is not empty, the values of all nodes on the right subtree are great ...

Posted by Lustre on Wed, 17 Nov 2021 02:02:14 +0100

Data structure -- implementation of stack

1, What is stack Structure and concept of stack: a special linear table that allows inserting and deleting elements only at a fixed end. One end for data insertion and deletion is called the top of the stack, and the other end is called the bottom of the stack. The data elements in the stack follow the principle of Last In First Out L ...

Posted by keefy on Sat, 13 Nov 2021 03:09:51 +0100