Interview frequency: what is the relationship between hashCode() and equals()?

First offer a picture, you can think about why? introduce equals() is used to determine whether two objects are equal. hashCode() is used to obtain hash code, also known as hash code; It actually returns an int integer. This hash code is used to determine the index position of the object in the hash table. relationship We use "class ...

Added by vronsky on Fri, 31 Dec 2021 21:30:51 +0200

11, Sequential list and linked list

1. Linearity table linear list is a finite sequence of n data elements with the same characteristics. It is a data structure widely used in practice. The common linear lists are: sequential list, linked list, stack, queue, string A linear table is logically a linear structure, that is, a continuous straight line. However, the physical stru ...

Added by gregzor on Fri, 31 Dec 2021 21:00:37 +0200

Data structure and algorithm

1. * * * the sum of the two numbers is the specified value Given an integer array, can you find two numbers so that their sum is a specified value? Example: if the input array is {1, 5, 7, 3} and the specified value is 10, we can find two numbers 3 and 7, and the sum is equal to 10. # The function call format is as follows # -*- coding: UTF ...

Added by notsleepy on Fri, 31 Dec 2021 09:55:38 +0200

Zero basic introduction to data structure (beginners can also understand): hash MAP

[import] how to store and query the following key value pairs? 1: Watermelon 2: Apples 3: Oranges Simple storage using array arr[N]: watermelonAppleOrange When storing, take the key value as the index, directly obtain the storage location through offset, and assign it: arr[1] = "watermelon"; arr[2] = "Apple"; arr[3] = "Orange"; ...

Added by kevinbarker on Fri, 31 Dec 2021 03:39:10 +0200

HashMap details a hair into the soul

1. Underlying data structure of HashMap The bottom layer of HashMap is array + linked list. After 1.8, red and black trees are introduced. 1. Data structure Array: for using subscript to find elements in the array, the time complexity is O(1); To find through the given value, you need to traverse the array and compare the given keywords and ...

Added by gkep on Thu, 30 Dec 2021 18:08:51 +0200

leetcode brush notes (continuously updated...)

1. Algorithm 1.1 dynamic planning 1.1. 1 simple topic 53. Maximum subsequence sum Given an integer array nums, find a continuous sub array with the largest sum (the sub array contains at least one element) and return its maximum sum. Method 1 /* Use f(i) to represent the "maximum sum of continuous subarrays" ending with the ...

Added by mfos on Thu, 30 Dec 2021 17:35:53 +0200

Using JavaScript to implement a simple web version calculator

background Because I was assigned to a new project team, the project needs js. Because I haven't contacted it, the leader is going to give me a week to study. Yes, realizing a simple calculator that supports four mixed operations is an assignment, so I have this article Therefore, the main focus of this article is not html and css. After all, ...

Added by stride-r on Thu, 30 Dec 2021 16:53:29 +0200

[java data structure] use of stack and queue

1. Stack Related concepts of stack **First of all, stack is a basic and commonly used data structure. Its characteristics are: first in and last out. The bottom layer can be realized by linked list or array. When using stack as a data structure, only one end of the array can be operated** One end of the insert and delete operation is the ...

Added by kwilameiya on Thu, 30 Dec 2021 16:24:52 +0200

Data structure: circular linked list to solve Joseph problem

josephus problem Origin of the problem It is said that the famous Jewish historian Josephus had the following story: after the Romans occupied jotapat, 39 Jews hid in a cave with Josephus and his friends. 39 Jews decided that they would rather die than be caught by the enemy, so they decided a way of suicide. 41 people lined up in a circ ...

Added by sullyman on Thu, 30 Dec 2021 10:56:13 +0200

Chapter 8 - shortest path

Shortest path problem For the algorithm operation of related concepts, see This article. Only the codes of Dijkstra algorithm and Floyd algorithm are introduced here. Dijkstra algorithm BFS can find the shortest path length from a point to another point. Dijkstra algorithm is mainly to find the shortest path length from a point to all oth ...

Added by mad_hacker on Thu, 30 Dec 2021 03:28:55 +0200