Daily training - day22

day22_0519 choice question 1: simply select the best time O(n^2) average time O(n^2) worst time O(n^2) 2: Directly insert the best time O(n) average time O(n^2) worst time O(n^2) 3: Bubble sort best time O(n) average time O(n^2) worst time O(n^2) 4: Hill sort ^ best time ^ O(n) average time O(logn) worst time ^ O(n^s) 1 < s < 2 ...

Posted by QuietWhistler on Fri, 20 May 2022 01:49:27 +0300

LeetCode algorithm path array part 1

LeetCode algorithm Most bogey, hope to do a series of articles to record the process of brushing algorithm. At present, it is mainly based on LeetCode https://leetcode-cn.com/circle/article/48kq9d/ The module of this post will brush the questions. The content is mainly the summary of the landlord in the post, as well as some personal experience ...

Posted by shak123 on Thu, 19 May 2022 20:46:21 +0300

leetcode top 100 questions - day 1: 1, 2, 3, 4

0. Always say It's time to pick up your studies that have been neglected for so long. Today is 2022-05-18. Brush at least two questions every day. I've written the first few times and directly abbreviated them. 1. 1. Sum of two numbers 1. Title Description 2. Topic analysis Traverse to find two numbers with mapping relationship, so y ...

Posted by php3ch0 on Thu, 19 May 2022 01:06:23 +0300

Dynamic Programming: The Knapsack Problem - 2. The Complete Knapsack Model

maximum value minimum value complete knapsack problem analyze state representation v ( i ) v(i) v(i): the first i ...

Posted by adeelahmad on Wed, 18 May 2022 22:07:04 +0300

indexOf principle, Java, javascript, python implementation

brief introduction We found that the front-end and back-end projects of indexf are very frequent, no matter when we are working on them recently! The meaning of indexOf: a given string matches the subscript of another string. If it matches, it returns the subscript. If it cannot match, it returns - 1. In fact, the principle is relatively simple ...

Posted by dbomb101 on Wed, 18 May 2022 20:40:42 +0300

How to reuse code gracefully with JDK and Spring?

preface Template, as the name suggests, is a fixed and standardized thing. Template method pattern is a behavior design pattern. It defines an algorithm framework in superclass, allowing subclasses to rewrite specific steps of the algorithm without modifying the structure. Scene problem Suppose we are masters of a beverage shop, we need at leas ...

Posted by thekidscareya on Wed, 18 May 2022 14:59:35 +0300

C++ binary search tree encoding and decoding

Serialize and deserialize binary search trees Title [leetcode449] Serialization is the process of converting a data structure or object into a series of bits so that it can be stored in a file or memory buffer, or transmitted over a network connection link for later reconstruction in the same or another computer environment. Design an algorithm ...

Posted by idire on Wed, 18 May 2022 13:53:33 +0300

Leetcode - 3Sum (ideas to solve problems, refer to other people's code optimization, and wrong solutions)

Topic description Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Now given an array of n integers, look for three numbers that add up to 0. Find all the different groups, each group consists of three numbers, and the sum of the t ...

Posted by BlueSkyIS on Wed, 18 May 2022 09:50:36 +0300

LeetCode greedy topic java code thinking solution

Constantly updating Problem solution 455 distribution of biscuits Suppose you are a great parent and want to give your children some cookies. However, each child can only give one biscuit at most. For each child i, there is an appetite value gi, which is the minimum size of biscuits that can satisfy the children's appetite; And every cookie ...

Posted by mechamecha on Wed, 18 May 2022 06:40:12 +0300

Algorithm & Union find algorithm

This article mainly introduces the parallel search algorithm 1, Dynamic connectivity Before introducing the algorithm, let's talk about what it is from and what problems it solves. First look at the diagram to understand dynamic connectivity. There are 10 points in the figure, one point pair is given at a time, for example (4, 3), which means ...

Posted by adhi_nugraha on Wed, 18 May 2022 06:16:46 +0300