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

Data structure and program design of leetcode in the direction of postgraduate entrance examination (miscellaneous articles such as number and stack, including train of thought solutions)

Digital problem 9. Number of palindromes Algorithm idea: 1. First, judge whether x is a negative number. If it is a negative number, it directly returns false without conversion 2. Assign the palindrome number y according to the flashback until Y > = X. at this time, if x = = y | x = = Y / 10, it is the palindrome number, otherwise it ...

Posted by elwadhos on Tue, 17 May 2022 18:01:13 +0300

leetcode | stack and queue

232. Implement queue with stack (simple) Use the stack to implement the following operations of the queue: push(x) -- put an element at the end of the queue. pop() -- removes the element from the queue header. peek() -- returns the element at the head of the queue. empty() -- returns whether the queue is empty. Example: MyQueue queue = new MyQ ...

Posted by marian on Tue, 17 May 2022 14:29:27 +0300

HDU - 1257 minimum interception system (dp three methods)

Title Link: [minimum interception system] General meaning: One shell of the interception system can reach any height to intercept enemy missiles, but this shell can not exceed the previous height in the future, that is, it can not intercept missiles higher than him again. Then give some missiles and ask how many interception systems are ne ...

Posted by mrheff on Tue, 17 May 2022 12:49:43 +0300

String reverse order - multiple methods

Reverse the order of strings, taking the string abcdef as an example 1. With additional arrays #include <stdio.h> #include <string.h> int main() { char str[] = "abcdef"; //Find the size of the string, including '\ 0' int sz = strlen(str) + 1; //Dynamic memory allocation, apply for a character array of sz size ...

Posted by zechdc on Tue, 17 May 2022 03:07:02 +0300

Classic problems of sliding window algorithm and general code summary

The questions are as follows: Give you a string s and a string t. Returns the smallest substring in s that covers t all characters. If there is no substring covering t all characters in s, the empty string "" is returned. be careful: For repeated characters in T, the number of characters in the substring we are looking for must not ...

Posted by subalan on Tue, 17 May 2022 02:00:21 +0300

[2D compression] | conditional image run length coding

1, Run length encoding The idea behind this data compression method is: if a data item d appears n times continuously in the input stream, replace n times with a single pair of nd. Then, the continuous occurrence of a data item is called run length N, and this method of data compression is called run length coding or RLE. We first apply ...

Posted by Quevas on Mon, 16 May 2022 22:50:47 +0300