Arts twelfth week (6/3 ~ 6/9)

What ARTS yes?
Mathimatics-Numerical algorithms : at least a week to do a leetcode algorithm problem;
Review : Read and review at least an English technical articles;
Tip : Learn at least one technical skills;
Share : Share ideas and think there is a technical article.


Algorithm

LeetCode 115. Distinct Subsequences

Ideas analysis

Title number obtaining means is a string (substring) occurring in the sequence of the other sub-string (main string), and then put it another way, the main stream is equal to the sequence number of substrings. A string matching problem, of course, we can consider the violence solved, probably thinking, we assume that the primary run length is n, m is the length of the substring, we select all sequences of length m in the main stream, see the sequence number is equal to substring, so the time complexity is very high, in fact, a combination of the time complexity of the problem, is the index level. So to consider the dynamic programming, basically string matching and related topics can be considered to try to paint the table, I started to get our hands on this question thought to use fixed return, the definition of the state is not too difficult, that is dp[i][j] -> 子问题 s[0...i], t[0...j] 的答案, but this recurrence equation think quite a long time, because no idea is also constantly trying to redefine the state, and finally painting table summarizes the law, and slowly came out; in general such a string matching problem, for the current problem, that is dp[i][j], we can go to observe the adjacent sub-problems dp[i - 1][j - 1], dp[i][j - 1], dp[i - 1][j], the string matching problem, we consider that a character comparison, so here there will only be two cases, relatively equal to the current character and current character compared are not equal, if equal to s[i] == t[j]sub-problem then we need to consider that s[0...i-1], t[0...j-1], for the answer to this question we have calculated the child had, yes dp[i - 1][j - 1], but that is not all, that is only part of the answer, the child also need to consider that question s[0...i-1], t[0...j], that is, remove s characters present s[i], the answer has been calculated, that is dp[i][j - 1], a lot of people may ask, so consideration will not be repeated? Actually not, because all of the current problem is not to consider the sub-problems s[0...i], t[0...j-1], but also will consider the issue of guarantee that the children will not be repeated, so to speak may not understand, draw a table would be better understood. If you say equal s[i] != t[j], then the sub-issues we need to consider is s[0...i-1], t[0,...j]the direct point that is, to remove the solution of the current character string in the range of current primary consideration.


Reference Code

public int numDistinct(String s, String t) {
    if (s == null || t == null || s.length() < t.length()) {
        return 0;
    }
    
    if (s.length() == 0 || t.length() == 0) {
        return 1;
    }
    
    char[] sArr = s.toCharArray();
    char[] tArr = t.toCharArray();
    
    // dp[i][j] -> answer for subproblem: s[0...i] and t[0...j]
    
    // if s[i] == t[j] -> dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
    // dp[i - 1][j - 1] means the count not consider s[i], which is s[0...i-1] match t[0...j-1]
    // dp[i][j - 1] means the count consider s[i], which is s[0...i] match t[0...j-1]
    
    // if t[i] != s[j] -> dp[i][j] = dp[i][j - 1]
    int[][] dp = new int[sArr.length][tArr.length];
    
    dp[0][0] = (sArr[0] == tArr[0] ? 1 : 0);
    for (int i = 1; i < sArr.length; ++i) {
        for (int j = 0; j < Math.min(i + 1, tArr.length); ++j) {
            if (sArr[i] == tArr[j]) {
                dp[i][j] = (j == 0 ? dp[i - 1][j] + 1 : dp[i - 1][j] + dp[i - 1][j - 1]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    
    return dp[sArr.length - 1][tArr.length - 1];
}
复制代码

Review

For the same two authors, points clear, Zhuo insightful article, talking about the program among the errors:

The Greatest Developer Fallacy Or The Wisest Words You’ll Ever Hear?

On The Value Of Fundamentals In Software Development

The first article tells of programmers familiar words, " I went to learn when needed ", this sentence is nothing wrong with this, because the computer software in the field of new technologies emerging, impossible to study all of them, and in order to learn to learn does not make sense. But now the problem is that many programmers these words as an excuse not to dig deep and specializes in knowledge , the author also gives a point of view, " you can not go learn something you did not know " how to understand? Let's say you just know that a Web Java Spring framework when you need to build Web server, you can only use Java Spring to consider, but in fact, in addition to this, there are Python's Django, JavaScript's Express, Ruby's Ruby on Rails, these are Web framework, but they apply to different scenarios, different difficult to get started, suitable for solving the problem are not the same, relative to the Java Spring, these are the technical knowledge to know you're not, do not know its advantages shortcomings, even if they are better, for you, is also equivalent to none. The authors suggest that we should become a T-type talent , he also pointed out that when you go in-depth specializes in a certain direction, you will learn a lot outside the joint in this direction , so the solution to the problem is for the interest you the things you need to learn some more in-depth, and not, on the surface, of course, with respect to the accumulation of knowledge, more important is the passion for this industry, most of the study to the final harvest will be effective and whether boils down to attitude .

The second article talking about the basics of learning, the author gives the definition of basic, from a macro point of view, the other is from the microscopic point of view, from a macro point of view, such as data structures and algorithms, operating systems, network knowledge of the agreement , the reason is the macro on, because these things tend to be universal, any technology will be based on this, for example, whether it is in Java ArrayList, or C ++, Vector, Python in the list, JavaScript in the list, these things are inherently dynamic array, just the way representation is not the same, if you understand the relevant knowledge and the origin of the data structures and algorithms of dynamic arrays, which you'll learn soon, will be handy to use other relevant knowledge, too. The reason is micro-micro, because of its implementation of specific technologies, such as Java's ArrayList for learning, you need to familiarize yourself with the API documentation to learn and master a variety of its common API functions and related operations, these things can help us to quickly write code, sometimes do not know an API or built-in function, tend to greatly affect the efficiency of our development. So summarize is the basis of learning on macro allows you to learn faster, learn the basis of microscopic above will let you achieve faster writing code efficiency and contrast the differences between the different techniques to achieve the effect of analogy .


Tip

A share mounted above Linux program instructions, screen commands, extremely simple to use, the following general steps:

>$ screen  
按 enter 键
>$ node ...      (这里输入命令)
ctr + A          (挂载)
ctr + D          (退出)
复制代码

This week look geeks above HTTP column, to learn some of the concepts of the network, did not know before, but some words frequently seen now with the concept, be it literacy, record it, consolidate it:

  • WWW World Wide Web is a subset of the Internet, which is based on HTTP protocol, HTML hypertext transfer resources
  • The CDN (the Content Delivery the Network) , is an intermediate portion of a client to the server, the HTTP application of caching techniques and agents, instead of responding to client requests source station
  • RPC (Remote Procedure Call) , Remote Procedure Call, is a computer protocol that allows a computer to call a subroutine on another computer, but programmers without additional programming for this operation
  • HTTPS is running on HTTP SSL / TLS, and TLS (Transport Layer Security) is a SSL (Secure the Socket Layer) over the development, use a lot of encryption algorithms
  • IP protocol is mainly to solve the addressing and routing problem, the TCP protocol is based on IP, IP-based protocol that provides a reliable byte stream communication form
  • Forward proxy refers to the client side of the proxy, reverse proxy refers to the proxy server

Share

This week read "Art sober thinking" this book, the book gives a 52 thinking errors, I think some misunderstanding for those of us programmers, or who want a career that is very worth learning

Typical thinking errors learning summary

Reproduced in: https: //juejin.im/post/5cf846c9f265da1bb80c1da2

Guess you like

Origin blog.csdn.net/weixin_34128501/article/details/91475679