The most detailed source code analysis for HashMap and Concurrent HashMap of Java base collection classes

HashMap Source Analysis HashMap is a common key-value collection implementation class in Java that implements the Map interface. data structure Core: The whole is an array;Each position of the array is a chain list (or a red-black tree);The Value in each node of the list is the Object we store; JDK 1.7 data structure Array+Chain List ...

Added by plapeyre on Fri, 19 Nov 2021 19:55:24 +0200

142. Ring linked list II

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *detectCycle(ListNode *head) { ListNode* temp = head; while(temp != nullptr && temp->val <100001){ temp-&gt ...

Added by elfynmcb on Fri, 12 Nov 2021 16:30:42 +0200

Data structure and algorithm -- jump table

What is a jump watch The full name of jump list is jump list. It allows you to quickly query, insert and delete a data linked list of ordered and continuous elements. The average search and insertion time complexity of the jump list is O(logn). Fast query is performed by maintaining a multi-level linked list, and the elements in each layer of ...

Added by ginger76 on Fri, 12 Nov 2021 07:06:04 +0200

Algorithm learning diary day07

The realization of adjacency matrix mainly uses two-dimensional array Establishment and traversal of adjacency matrix: import numpy as np class AdjacencyMatrix(): #Adjacency matrix class def __init__(self,n=2): self.Matrix=np.zeros((n,n)) #Fill 2D array with 0 def getMatrix(self): #Print adjacency ...

Added by gclx on Fri, 12 Nov 2021 02:11:37 +0200

[completion algorithm] merge two ordered linked lists

Merge two ordered linked listsLeetCode21. Merge two ordered linked listsProblem descriptionInput two monotonically increasing linked lists and output the synthesized linked list. We need the synthesized linked list to meet the monotonic non decreasing rule.Example:Input: {1,3,5}, {2,four,6}Return value: {1,2,3,4,5,6}Analyze problemsSince the gi ...

Added by tam2000k2 on Mon, 08 Nov 2021 14:53:10 +0200

Linear table -- dynamic sequence table

preface This chapter introduces the storage elements in the data structure - the sequential table in the linear table Linear table A linear list is a finite sequence of n data elements with the same characteristics. Linear table is a data structure widely used in practice. Common linear tables: sequential table, linked list, stac ...

Added by vegnadragon on Mon, 08 Nov 2021 10:18:29 +0200

Two problems of merging and dividing leetcode linked list

1. Merge two ordered linked lists 1.1 Title Description This topic comes from leetcode 21. Merging two ordered linked lists Tips: 1.2 interface function /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* mergeTwoLists(struct ListNode* l1, struct ...

Added by B34ST on Sat, 06 Nov 2021 07:36:12 +0200

[Java data structure - linear table] detailed summary of 20000 word hard core, with detailed graphic source code, which is worth collecting

catalogue ๐Ÿ™Œ Write in front ๐Ÿ™Œ Linear table ๐Ÿ™Œ Sequence table ๐ŸŽถ Concept and structure ๐ŸŽถ Interface implementation ๐ŸŽถ Create sequence table ๐ŸŽถ Print sequence table ๐ŸŽถ Gets the effective length of the sequence table ย  ๐ŸŽถ Add element in pos position โ€‹ ๐ŸŽถ Determine whether an element ๐ŸŽถ Find the corresponding position of an element ...

Added by Bourgeois on Sat, 06 Nov 2021 04:01:12 +0200

Force button brush problem list No. 2 precise solution of adding two numbers

0. Title link Force buckle ย  1. Topic analysis 2. Add two numbers Medium difficulty 7007 Here you are ย  Non empty ย  A linked list that represents two nonnegative integers. Each of these numbers is based on ย  Reverse order ย  And each node can only store ย  One ย  Number. Please add the two numbers and return ...

Added by ramez_sever on Sat, 06 Nov 2021 01:27:43 +0200

Data structure Chapter 1 - sequence table

1, Sequence table 1. Merging of two ordered linked list sequences Two non descending linked list sequences S1 and S2 are known, and the function is designed to construct a new non descending linked list S3 after the combination of S1 and S2. Input format: The input is divided into two lines. Each line gives a non descending sequence composed o ...

Added by thetick on Fri, 05 Nov 2021 21:34:19 +0200