leetcode this week

1. Find the 3-bit even number Give you an integer array digits, where each element is a number (0 - 9). There may be duplicate elements in the array. You need to find all integers that meet the following conditions and are different from each other: The integer consists of three elements in digits connected in any order. The integer does not co ...

Posted by andrewholway on Sun, 05 Dec 2021 09:49:05 +0100

[data structure] linked list 04: LeetCode 21. Merge two ordered linked lists, LeetCode 23. Merge K ascending linked lists

1, LeetCode 21. Merge two ordered linked lists Method 1: iteration Code and performance class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode dummy = new ListNode(-1); ListNode p = dummy; ListNode p1 = l1; ListNode p2 = l2; while(p1 != null && p2 != null){ ...

Posted by troybtj on Sun, 28 Nov 2021 09:21:52 +0100

Chain structure of binary tree and some basic operations on chain binary tree

This paper summarizes some basic operations of chained binary tree in class, including Calculate the number of nodes of the binary treeCalculate the number of leaf nodes of binary treeCalculate the number of nodes in the K-th layer of the binary treeCalculate the depth / height of the binary treeFind and return the node with the value of x ...

Posted by Jenling on Sun, 21 Nov 2021 00:57:15 +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

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] graph and graph traversal (depth traversal and breadth traversal)

chart In mathematics, a graph is a structure described in a group of objects, some of which are "related" in a sense. These objects correspond to mathematical abstractions called vertices (also known as nodes or points), and each associated vertex pair is called an edge (also known as a link or line). Usually, a graph is depicted ...

Posted by simwiz on Fri, 12 Nov 2021 13:45:43 +0100

c + + < set > set() usage

  There are several questions about set: (1) Why is the insertion and deletion efficiency of map and set higher than that of other sequence containers? Most people say that it is very simple, because there is no need to copy and move memory for associated containers. Yes, indeed. All elements in the set container are stored in the form o ...

Posted by pabs1983 on Thu, 11 Nov 2021 09:34:13 +0100

[completion algorithm] sorting of single linked list

More algorithm solutions, please pay attention to the official account, "programmer"Sorting of single linked listProblem descriptionLeetCode 148. Sorting linked listGiven an unordered single linked list with n nodes, it is sorted in ascending order.Requirements: space complexity O(n), time complexity O(nlogn).Example:Input: [- 1,0, - ...

Posted by RSprinkel on Mon, 08 Nov 2021 08:59:44 +0100

HashMap Implementation Details (Java 8)

1 Introduction Differences between HashMap before and after Java 8: Contrast ItemBefore Java 8After Java 8 (including)Node typeEntryNode/TreeNodestorage structureArray + One-way Chain ListArray + One-way Chain List / Red-Black TreeInsertion methodHead InterpolationTail interpolationExpansion timingExpand before insertingInsert before expandha ...

Posted by TGLMan on Sun, 07 Nov 2021 18:08:40 +0100

Java collection framework

Set framework generalization A collection can be regarded as a container for storing object information. Some excellent algorithms and data structures are encapsulated in the collection framework of Java. The Collection interface stores a set of non unique and unordered objectsThe List interface stores a set of non unique and ordered obje ...

Posted by bhogg on Sun, 07 Nov 2021 02:54:08 +0100