Sword finger Offer: [day 1 stack and queue (simple)] --- > stack containing min function

1, Title Description To define the data structure of the stack, please implement a min function that can get the smallest element of the stack in this type. In this stack, the time complexity of calling min, push and pop is all. O ( 1 ...

Posted by steelerman99 on Tue, 15 Feb 2022 14:00:23 +0100

Sequential list and linked list

1, Linear table Linear table: when data is stored, it is stored continuously according to logic and forms a linear structure (feature: all have the concept of index, and the elements with smaller index must be logically arranged before the elements with larger index) Linear list subset: sequential list, linked list, stack, queue, string ...

Posted by rsasalm on Tue, 15 Feb 2022 13:20:42 +0100

Introduction to prefix, infix and suffix expressions (implemented by computer code)

1. Prefix, infix, suffix expression 1.1 prefix expression (Polish expression) Prefix expression is also called polish. The operator of prefix expression is before the operand, Examples: (3 + 4) × The prefix expression corresponding to 5-6 is [- x+3456] Computer evaluation of prefix expressions Scan the expression from right to ...

Posted by Youko on Tue, 15 Feb 2022 06:05:16 +0100

Discussion on data structure

All the code in this article is written in C + + 4 double linked list, circular linked list and static linked list 4.1 double linked list 4.1.1 definition of double linked list In the previous knowledge, we once said that because each data element in the single linked list is divided into two parts - data field and pointer field, the ...

Posted by rupertbj on Mon, 14 Feb 2022 17:35:08 +0100

[leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line

Day 34 540 a single element in an ordered array Give you an ordered array of integers, where each element will appear twice and only one number will appear once. Please find and return the number that appears only once. The solution you design must meet O(log n) time complexity and O(1) space complexity. method Since all elements in the a ...

Posted by atyndall on Mon, 14 Feb 2022 14:33:23 +0100

From introduction to mastery of Java (Java data structure -- Map Collection)

Map interface description (double column set) JavaApi gives a partial overview of the Map interface An object that maps keys to values. A mapping cannot contain duplicate keys; Each key can be mapped to at most one value. The Map interface provides three collection views that allow you to view the contents of a Map in the form of key ...

Posted by tequila on Mon, 14 Feb 2022 14:03:42 +0100

LeetCode 148. Sort linked list

subject Give you the head node of the linked list. Please arrange it in ascending order and return the sorted linked list. Example 1: Input: head = [4,2,1,3] Output: [1,2,3,4] Example 2: Input: head = [-1,5,3,4,0] Output: [- 1,0,3,4,5] Example 3: Input: head = [] Output: [] Tips: The number of nodes in the linked list is in th ...

Posted by F.Danials on Mon, 14 Feb 2022 09:01:46 +0100

Bubble sorting and optimization of bubble sorting - > cocktail sorting

What is bubble sorting Bubble Sort is the most basic exchange sort. Everyone must have drunk soda. There are often many small bubbles floating on it. This is because the carbon dioxide that makes up small bubbles is lighter than water, so small bubbles can float upward bit by bit. The basic idea of Bubble Sorting is to compare the values of ...

Posted by snowdog on Mon, 14 Feb 2022 04:16:15 +0100

Algorithm and tree structure

Tree structure: tree structure is a data structure that describes nonlinear hierarchical relationships. A tree is a set of n data nodes, which contains a root node. Under the root node, there are some non intersecting subsets, which are subtrees of the root node. Basic characteristics of tree structure: (1) In a tree structure, there is only ...

Posted by blackwidow on Mon, 14 Feb 2022 02:56:02 +0100

[Template Summary] - Binary Search Tree BST - Basic

Template Title Link BST Lookup- Leetcode 270. Closest BST ValueBST Insert- Leetcode 701. Insert Node in BSTBST Delete- Leetcode 450. Delete Node in BST Binary Search Tree-BST Overview BST is a kind of binary tree, which has the structural properties of binary tree: there is only one Root node, each node can have at most two left and right sub ...

Posted by Quadodo on Sun, 13 Feb 2022 18:42:38 +0100