Tag:array

  • For loop traversal in JavaScript

    Time:2021-3-7

    General for loop traversal Define an array: Using the normal for loop traversal Can be used to traverse arrays Foreach traversal The traversal code is as follows This structure is more concise, but you can’t use break and other statements to jump out of traversal until all elements are passed to the calling function, but […]

  • [algorithm] implementation of classic sorting algorithm 1 in PHP

    Time:2021-3-7

    1、 Bubble sort Brief introduction of principle Bubble sort is a simple and common sort algorithm. It traverses the sequence of numbers to be sorted, compares the size of the two values, and exchanges the positions of the two wrong numbers to complete the sorting. Repeat the above operation until there is no exchangeable number […]

  • SDS of redis data structure

    Time:2021-3-6

    SDS(simple dynamic string), simple dynamic string. S and it’s called hacking string. Where hack is stored is the length of the string and the remaining space in SDS. The implementation of SDS insds.cIn the middle. C language string uses a character array of length N + 1 to represent the string of length N, and […]

  • Redis – Chapter 10 – linked list

    Time:2021-3-6

    catalog Arrays and linked lists Linked list contrast summary 1. Arrays and linked lists Array: Array will open up a continuous space in memory to store data, which has both advantages and disadvantages. When obtaining data, the corresponding elements can be obtained directly through the subscript value, and the time complexity isO(1). But if you […]

  • [caption - dynamic programming - interview] masseuse – leetcode

    Time:2021-3-6

    Title: masseuse   A famous masseuse will receive a steady stream of appointment requests, each appointment can choose to accept or not. There is a break between each appointment, so she can’t accept adjacent appointments. Given an appointment request sequence, find the optimal appointment set for the masseuse (the total appointment time is the longest), […]

  • Common functions of JavaScript handwritten array

    Time:2021-3-5

    preface In the development process, we often use some elements of arrayapiRelated operations, includingforEach、filter、find、findIndex、map、some、every、reduce、reduceRightThe equivalent function method. Today, let’s try to write these functions by hand and implement these functions by array. For convenience, the array prototype object is created directly in theprototypeExpand on. Reading three series: like (), attention (), collection (). this paperGithabHas […]

  • Build high-performance queue, you have to know the underlying knowledge!

    Time:2021-3-5

    preface This article is included in the album:http://dwz.win/HjK, click to unlock more knowledge of data structure and algorithm. Hello, I’m brother Tong. In the previous section, we learned how to rewrite recursion as non recursion, in which the data structure used is mainly stack. Stack and queue are the most basic data structures in addition […]

  • [go] gocron source code reading – literal initialization syntax of array and slice in go language

    Time:2021-3-5

    There is a sentence in the source code that this function requires to return [] cli.Command , cli.Command Type slice. This place initializes a slice directly with literal value and returns it return []cli.Command{command}   Array literal initialization, generally need to specify the size of the array, you can use… Three points to replace the […]

  • Summary of the interview questions of the latest PHP senior engineers in large factories in 2020 (1)

    Time:2021-3-5

    1. Give you four coordinate points to judge whether they can form a rectangle. For example, judge whether ([0,0], [0,1], [1,1], [1,0]) can form a rectangle. Let’s analyze the problem and give 4 punctuation points to judge whether it is rectangular or not High school knowledge, rectangle has four sides, two equal, rectangular two diagonal […]

  • [development experience] safe value of function / nested map in flutter

    Time:2021-3-4

    DART’s null judgment Dart language has provided a lot of grammar sugar to improve the writing method of judging null value, but there are two situations that are not easy to judge judgefunctionIs it empty In this case, you often need to write code like this: Problem code Function(String) filter; //Must write an if, actually […]

  • Golang reads the JSON data stream of the file, parses it into struct, and stores it in the database

    Time:2021-3-3

    It’s hard to do it, but it’s easy to do it ..Directly select the JSON file to upload, no need to store the file package controller import ( “encoding/json” “errors” “fmt” “gindemo/middleware” “github.com/gin-gonic/gin” ) type User struct { Uid string `json:”uid”` Owner string `json:”owner”` User string `json:”user”` } type Json struct { } func Loadfile(c […]

  • Is JavaScript simple? Do you really understand foreach right?

    Time:2021-3-3

      you understandArray.prototype.forEachReally, right? Array.prototype.forEach    we all know,forEach()Method executes the given function once for each element of the array. Its syntax is also very simplearr.forEach(callback(currentValue [, index [, array]])[, thisArg]): Callback: function executed for each element in the array, which takes one to three arguments: Currentvalue: the current element being processed in the array. […]