LeetCode classification: find two

Find actual combat Case 1: sum of two numbers Given an integer array nums and a target value target, please find the two integers with and as the target value in the array and return their array subscripts. You can assume that each input will correspond to only one answer. However, the same element in the array cannot be used twice. Example: G ...

Posted by onewaylife on Fri, 20 May 2022 12:03:25 +0300

Niuke sword finger Offer - java version

Sword finger Offer - java version JZ01 In a two-dimensional array (each one-dimensional array has the same length), each row is sorted in ascending order from left to right, and each column is sorted in ascending order from top to bottom. Please complete a function, input such a two-dimensional array and an integer, and judge whether the arra ...

Posted by hagman on Fri, 20 May 2022 06:37:47 +0300

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