leetcode 12 interesting topics in life

121. The best time to buy and sell stocks [logic] Given an array of prices, its ith element prices[i] represents the price of a given stock on day I. You can only choose to buy this stock one day and sell it on a different day in the future. Design an algorithm to calculate the maximum profit you can make. Return the maximum profit you c ...

Posted by jotgabbi on Sat, 18 Dec 2021 23:17:33 +0100

Codeforces Round #761 (Div. 2) (A~D2)

Codeforces Round #761 (Div. 2) A. Forbidden Subsequence subject Knowledge points sort Problem solving ideas According to the meaning of the topic, it is easy for us to know when T = a b c ...

Posted by dud3r on Fri, 17 Dec 2021 10:10:12 +0100

Analysis of Common Algorithms: Greedy Algorithms

1. Greedy strategy: The so-called greedy strategy is to make the best choice in the current situation at each step and get the global optimal solution by summing up the local optimal solutions. Of course, a topic may not be able to obtain a global optimal solution from a local optimal solution (a typical example is the shortest path problem), ...

Posted by jvrothjr on Tue, 14 Dec 2021 20:09:21 +0100

Leetcode question group 39 (greedy)

134. Gas stations There are , N , gas stations on a ring road, of which the , I , gas station has , gas[i] liters of gasoline. You have a car with unlimited fuel tank capacity. Driving from the i-th gas station to the i+1 , th gas station requires , cost[i] liters of gasoline. You start from one of the gas stations and start with a ...

Posted by hillbilly928 on Tue, 14 Dec 2021 05:22:55 +0100

[algorithm thousand question case] daily LeetCode punch in - 86. Create string according to binary tree

📢 preface 🚀 Algorithm problem 🚀 🌲 Punching out an algorithm problem every day is not only a learning process, but also a sharing process 😜🌲 Tip: the problem-solving programming languages in this column are C# and Java🌲 To maintain a state of learning every day, let's work together to become the great God of algorithm ...

Posted by farzal on Mon, 29 Nov 2021 17:31:10 +0100

Minimum value problem of piggy bank (java)

1. Subjective questions   (100 points) Experiment 6: use dynamic programming algorithm to solve the problem of saving money (complete the contents of experiment report 3, 4, 5 and 6) 1, Experimental purpose         Practice using dynamic programming algorithms to solve practical problems (implemented in the ...

Posted by smileyriley21 on Sun, 28 Nov 2021 19:08:19 +0100

LeetCode: Buying and selling stocks II

Title Description Given an array prices, where   prices[i] is the price of a given stock on day I. Design an algorithm to calculate the maximum profit you can make. You can complete as many transactions as possible (buying and selling a stock multiple times). Note: you cannot participate in multiple transactions at the same time (you mu ...

Posted by wchris on Fri, 12 Nov 2021 00:20:17 +0100

Day 12_ Dynamic programming [introduction to algorithm]

70. Climb stairs Simple difficulty Suppose you are climbing stairs. You need n steps to reach the roof. You can climb one or two steps at a time. How many different ways can you climb to the roof? Note: given n is a positive integer. Example 1: Input: 2 Output: 2 Explanation: there are two ways to climb to the roof. 1. 1 rank + 1 ra ...

Posted by airwinx on Sun, 07 Nov 2021 05:18:11 +0100

Greedy algorithm java

Minimum dictionary order Given a string type array strs, find a splicing method so that the string formed after splicing all strings has the smallest dictionary order public class LowestLexicography { public static class MyComparator implements Comparator<String>{ @Override public int compare(String o1, Str ...

Posted by simrx11 on Thu, 04 Nov 2021 11:13:53 +0100

Noip simulation 85 2021.10.29 (to depression Trilogy)

preface Thanks to the author, I was directly depressed in the examination room Although I only saw Darling in the FRANXX, I still felt bad for \ (ichigo \) for a long time T1 \ ((ichigo) \) I came to see you dressed up like you like, Guang, no, da, darling Uncomfortable!!! But it's hard for me to cut \ (T1 \) without cutting it off On the exa ...

Posted by le007 on Fri, 29 Oct 2021 12:32:40 +0200