ARTS Week 17


This week’s LeetCode problem is 121. Best Time to Buy and Sell Stock

You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.

To achieve the maximum profit, then we have to make the buy price as low as possible and the sell price as high as possible, so when the loop traverses the array, if the current price is lower than the previous minimum buy price, then update the minimum buy price, and then compare if the current profit (current price — previous minimum price) is greater than the maximum profit, then update the maximum profit.


This week’s Review is for the following article: “Open source” is not broken

Many people know what happened recently in log4j. No one contributed to the original author. Whose fault is this? Authors If FOSS (Free and Open Source) is destroyed, then the Internet as we know it today will no longer exist; FOSS is a beautiful system that does not distinguish between national boundaries, races, beliefs and economic backgrounds, and gives everyone the same power .

FOSS was destroyed because it was abused by some users, and FOSS was the victim rather than the culprit in the process. There are several main reasons. The first problem is to maximize profit. To maximize profit, the cost must be minimized. Therefore, the company will not pay for it when adopting FOSS. Although it is unethical, this It’s not illegal. But then again, how should a FOSS be priced? Should a simple CSS library, log library, or even a database use the same pricing or different pricing?

FOSS is not black-and-white. So why are so many people involved in the development of FOSS? The author takes himself as an example, because he likes it, he does not expect to get a monetary return, and seeing people use the software he writes makes him feel Happy. This is the beauty of FOSS.


The method of using gettimeofday() function and struct timeval to count time in Linux is as follows:


This week I want to share a useful website: Programming Language and compiler Benchmarks

As the title indicates, this website records and counts the compilation and running time of different languages under same programs. The mainstream languages, including C, C++, Java, JavaScript, Python and so on.

For example, C language, it also compares the performance of the same program under different compilers, including gcc, clang, and so on.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store



A programmer. Share knowledge of programming, operating system, Linux kernel, and reading, thinking etc. Let us maintain a beginner mend and grow together!