Tag:Section

  • Some usages of dataframe

    Time:2021-4-18

    Some usages of dataframe in pandas Pandas reading excel file pd.read_excelThe prerequisite is to install the xlrd library Conversion between dataframe, numpy and list Dataframe to numpy: dataframe object. Values Dataframe to list: dataframe object values.tolist () List to numpy: np.array (list object) List to dataframe: pd.DataFrame (list object) Numpy to list: numpy object. Tolist […]

  • Detailed explanation of binary search algorithm

    Time:2021-4-17

    Binary search [toc] The most basic binary search int binarySearch(int[] nums, int target) { int left = 0; int right = nums.length -1; // Note while(left <= right) { Int mid = left + (right – left) / 2; // Note: if (right + left) / 2 is used, overflow will occur if(nums[mid] == target) […]

  • Sister Qi Comics: sorting algorithm (3) “fast sorting”

    Time:2021-4-17

    algorithm First select a benchmark pivot, then go through the array, Move everything smaller than pivot to the left of pivot, Move everything larger than pivot to the right of pivot. In this way, the position of the pivot is determined, that is, one element is arranged. Then sort the numbers to the left of […]

  • Discover the beauty of data structure stack

    Time:2021-4-14

    In the world of code, stack is a very important data structure no matter what language it is.Stack overflow, the world-famous code query community, takes stack overflow as a part of the website name.In the process of writing code or debugging, I believe you have felt the joy of skipping in the world of function […]

  • Let’s introduce the principle of golang for range loop with two examples

    Time:2021-4-14

    Is the following code a dead loop? func main() { v := []int{1, 2, 3} for i := range v { v = append(v, i) } } The above code first initializes a file with contents of 1, 2 and 3sliceAnd then traverse thissliceAnd then add elements to the slice. As the traversal proceeds, the […]

  • The beauty of discovery algorithm – sorting

    Time:2021-4-12

    What is sorting? First knowledge Algorithm diagram Sorting in JavaScript Normal sort Complex sorting Encapsulation of complex sorting function Lodash (v4.17.15) sort function Looking at sort () Bihui classic sorting algorithm Bubble sort (max end sort) Select sort (minimum value first sort) Insert sort (find position sort) Merge sort (binary recursive sort) Quick sort (base […]

  • High frequency interview questions: Dutch flag questions

    Time:2021-4-11

    The Dutch flag problem is also called tricolor sorting, or rainbow sorting, Because the Dutch flag has only three colors, the problem of this question is to give you three colors and arrange them in the given order. Of course, there are various ways to ask questions, some for numbers, some for letters, but the […]

  • Go: built in function | closure | array | slice | sort | map | lock

    Time:2021-4-2

    Built in functions 1. Close: it is mainly used to close the channel 2. Len: used to find the length, such as string, array, slice, map and channel 3. Both new and make are used to allocate memory New is used to assign value types, such as int and string, and returns a pointer Make […]

  • Leetcode 128. Longest continuous sequence | Python

    Time:2021-3-30

    128. Longest continuous sequence subject Given an unordered integer array, find out the length of the longest continuous sequence. The time complexity of the algorithm is O (n). Example: Input: [100, 4, 200, 1, 3, 2]Output: 4Explanation: the longest continuous sequence is [1,2,3,4]. Its length is four. Thinking of solving problems Idea: hash table The […]

  • Go series tutorial – string

    Time:2021-3-22

    1. What is a string? In go language, string is a byte slice. By placing the content between double quotation marks, we can create a string. Let’s take a look at a simple example of creating and printing a string. package main import ( “fmt” ) func main() { str := “hello golang” fmt.Println(str) } […]

  • Go language variable parameters

    Time:2021-3-19

    In recent discussions with colleagues, I mentioned the importance of go languageVariable parametersWe have not summarized the relevant knowledge points before. Today we will introduce the variable parameters of go language. Variable parameters(Variable Parameters)Function with variable number of parameters is called variable parameter function, which is mainly used inGrammar sugar(syntactic sugar)。 The most classic example […]

  • Notes on data structure Deng Junhui of Tsinghua University Chapter 2

    Time:2021-3-17

    Chapter 2 vector VectorIt is an abstraction and generalization of linear array. Starting from the most basic interface of vector, the corresponding vector template class is designed and implemented. a. Operation interface supported by vector ADT Operation interface function Applicable objects size() The current size of the report vector (total number of elements) vector get(r) […]