ARTS Week 19


This week’s LeetCode problem is 5. Longest Palindromic Substring

Given a string s, return the longest palindromic substring in s. For example, Input: s = "babad", Output: "bab"

This problem is solved using dynamic programming, the core of which lies in finding the state transfer equation. By observing that the echo string is still an echo string after removing the first and last two characters, i.e. dp[i][j] = dp[i+1][j-1] ^ (s[i] == s[j]), plus the initial condition when there are only one or two characters, so the state transfer equation is.

According to the state transfer equation, it is easy to write the code, mainly to record the start index and length of the longest echo substring in order to get that echo substring easily.


This week’s Review is for the following article: Don’t Panic! Your ram is fine!

Because the disk cache exists in the Linux system, its purpose is to make the system faster. When you need more memory, the disk cache will be automatically released to meet the needs of the application or process. Although you cannot turn it off, but you want to forcefully clear the current cache, you can run echo 3 | sudo tee /proc/sys/vm/drop_caches.

But when we use the top or free command to view the memory, we often find that the memory has been used, but this is actually because the free and available in the Linux system are different from our usual concepts Different, their comparison table is as follows:

Memory that is You’d call it Linux calls it used by applications Used Used used, but can be made available Free (or Available) Used (and Available) not used for anything Free Free

To see how much ram your applications could use without swapping, run free -m and look at the “available” column:

A healthy Linux system with more than enough memory will, after running for a while, show the following expected and harmless behavior:

  • free memory is close to 0
  • used memory is close to total
  • available memory (or "free + buffers/cache") has enough room (let's say, 20%+ of total)
  • swap used does not change

Warning signs of a genuine low memory situation that you may want to look into:

  • available memory (or "free + buffers/cache") is close to zero
  • swap used increases or fluctuates
  • dmesg | grep oom-killer shows the OutOfMemory-killer at work


A two-dimensional array in Python calculates the average value of each column by column. You need to use the numpy package and call the numpy.average(data, axis=0) statement to execute. When axis=1, calculate the average value by row , The example is as follows:


Happy New Year and good luck in everything!



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!