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

P6186 bubble sort (tree array + thinking)

1. The number of exchanges in each round of bubble sorting is equal to N - x, and X is the number of numbers that meet the following conditions: there is no larger number in front of this number We say that this number does not participate in the exchange in the current round of bubble sorting 2. The total number of rounds of bubble sort exc ...

Posted by moboter on Tue, 17 May 2022 23:30:21 +0300

String full permutation algorithm_ C # version_ Sword finger OFFER

String full permutation algorithm_ C # version_ Sword finger OFFER Title Description Title Description Enter a string of length n and print out all the permutations of characters in the string. You can return this string array in any order. For example, if you input string ABC, all strings ABC,ACB,BAC,BCA,CBA and CAB that can be arranged b ...

Posted by saronoff on Tue, 17 May 2022 22:43:15 +0300