Tag:Odd number

  • I want to tell you: private methods can be defined in Java interfaces


    In traditional Java programming, a well-known knowledge point is:Private method cannot be defined in java interface interface。 Only methods, abstract methods or static methods that allow us to define public access rights are allowed. However, starting with Java 9, private methods and private static methods are allowed to be defined in the interface interface. Now […]

  • Go channel VS Java BlockingQueue


    preface Recently, we are implementing two requirements. Since there is no dependency between them, we want to use queue to decouple them; But inGoThere is no readily available and concurrent secure data structure in the standard library of; butGoProvides a more elegant solution, that ischannel。 Channel application GoAndJavaOne big difference is that the concurrency model […]

  • The problem of auto balancing when the nodes of echart graph are deleted


    Project scenario: Project scenario: a node X and Y in the echarts diagram are fixed,To center the same column, which stipulates:The current column has an odd number of elements, and the new nodes are put down. When there are even numbers of nodes, the new nodes are put up。 Problem Description: If you delete an […]

  • Go brush questions every week for the fourth week


    Start the leetcode series of dynamic programming. Self supplement related to theoretical knowledge points, old rules, or start with simple topics. Leetcode70 This is an entry-level topic. Find the total number of methods for N steps. When you reach the last step n, there are only two situations, one is from n-1 (one step) and […]

  • Clever use of Python for in


    import random Ou = “even”Ji = “odd”a = range(1,11) x = 0 while x < 10: list = random.sample(a,10) print(list) if list[0] % 2 != 0: print(ji, end=”,”) else: print(ou, end=”,”) if list[1] % 2 != 0: print(ji, end=”,”) else: print(ou, end=”,”) if list[2] % 2 != 0: print(ji, end=”,”) else: print(ou, end=”,”) if list[3] […]

  • Golang exercise, reversing slices


    package main import ( “fmt” ) func main() { var s1 []int = []int{1,2,3,4,5,6} var s2 []int = []int{1,2} rotate(s1) rotate(s2) fmt.Println(s1) fmt.Println(s2) } func rotate(s []int){ left,rigth := 0,0 If len (s)% 2 = = 0{// judge whether the length is odd or even, and determine the center of rotation according to this left […]

  • How to calculate pi with C language π( Three methods)


    Topic 1: Calculation by Formula 1 π It is required to accumulate until the last term is less than 10 ^ (- 6). Program code: #include #include #include int main(){ float s=1; float pi=0; float i=1.0; float n=1.0; while(fabs(i)>=1e-6){ pi+=i; n=n+2; //The design here is very clever. The sign is different every time s=-s; i=s/n; […]

  • LeetCode 1248


    Portal: https://leetcode-cn.com/probl… First, estimate the violent solution: loop through each subarray to determine whether it is a graceful subarray, and the odd number of the array needs to be obtained in the judgment process. It is not advisable to estimate o (N3).dynamic programmingFor this problem, we can decompose the problem and use the results of […]

  • Sharding JDBC is used to separate database and table, and read and write are separated


    Sub database and sub table Why do we have to divide the database and table? The amount of data in the database is uncontrollable. With the development of time and business, there are more and more data in the table. If you curd the database table again, it will cause performance problems. In order to […]

  • JS map filter array


    Find out all the scores above 60 let scores = [95,91,59,55,42,82,72,85,67,66,55,91] let scores2 = scores.filter(item => item>60 ?) console.log(scores2) // [95,91,82,72,85,67,66, 91] Turn numbers into weeks let arr = [0,1,2,2,3,3,3,4,4,4,4,6] let arr2 = arr.map((item) =>{ return{ 0: ‘Monday’, 1: ‘Monday’, 2: ‘Tuesday’, 3: ‘Wednesday’, 4: ‘Thursday’, 6: ‘Saturday’ }[item] }) console.log (arr2) // [‘sunday ‘,’ […]

  • In a word, it’s a recurrence


    Modification record: 2021.2.6 The format of the problem is unified 2021.2.3 At the end of the article, we add the recursive review link of big brother Ah, what is recursion? Namely: fromKnownreachunknown。Using observation to find the previous known data, we can get the conclusionRecurrence formulaAnd then the recursive formula is used to solve the problem. […]

  • C practical exercise topic 3


    Title:An integer, after adding 100, is a complete square number, and then 168 is a complete square number. What is the number? Program analysis: Suppose the number is X. 1. Then: x + 100 = N2, x + 100 + 168 = m2 2. Calculation equation: M2 – N2 = (M + n) (M – […]