Origin of Ray

Lift the fog of the Internet together

Principle

The idea of the sliding window algorithm is this:

  1. We use the left and right pointer trick in the double pointer in string S, initialize left = right = 0, and call the index closed interval [left, right] a “window”.

  2. We first keep increasing the right pointer to expand the window [left, right] until the string in the window meets the requirements (including all the characters in T).

  3. At this point, we stop adding right, and instead keep increasing the left pointer to shrink the window [left, right] until the string in the window no longer meets the requirements (does not contain all the characters in T). At the same time, every time we increase left, we have to update the result one round.

  4. Repeat steps 2 and 3 until the end of string S is reached to the right.

Read more »

Through a topic地图分析, to explain and practice BFS.

Principle

Consider the simplest method, which is to find each ocean area (grid [i] [j] 0 的区域)的「最近陆地区域」,然后记录下它们的距离,然后在这些距离里面取一个最大值。

Read more »

Recently, I encountered recursion when I was doing the question. I vaguely felt that it was a bit similar to the motion gauge, but I couldn’t explain it clearly, so I found a lot of articles. Here is an excerpt of the most basic but also the most clear article. The original link is这个

Principle

The general form of Dynamic Programming problem is to find the best value. Dynamic Programming is actually an optimization method of operations research, but it is more used in computer problems, such as asking you to find the longest increasing sequence, the minimum editing distance, and so on.

Since it requires the most value, what is the core problem? The core problem of solving Dynamic Programming is exhaustion. Because the most value is required, you must exhaust all feasible answers and then find the most value among them.

Dynamic Programming is so simple, is it exhaustive? The Dynamic Programming problems I see are all very difficult!

First of all, the exhaustion of Dynamic Programming is a bit special, because there are “overlapping sub-problems” in this type of problem, and the efficiency will be extremely low if the brute force exhaustion is used, so “memo” or “DP table” is needed to optimize the exhaustion process and avoid unnecessary computation.

Read more »

Principle

Recently, I encountered several backtracking algorithms when I was doing problems, and each time I tried them out slowly, so I went to find out if there was any abstract ideas that I could refer to, so I looked for many articles, and here is an excerpt of the most basic but also the most clear article, the original link is this permutations/solution/hui-su-suan-fa-xiang-jie-by-labuladong-2/).

Solving a backtracking problem is actually a decision tree traversal process. You only need to think about 3 questions:

  1. Path: that is, the choices that have been made.

  2. The list of choices: that is, the choices you can currently make.

3, the end condition: that is, the condition that you can no longer make a choice when you reach the bottom of the decision tree.

Read more »

After having the IP Address and the design of the routing table, we must continue to consider how to obtain routing information, that is, how to exchange information between routers, such as how to express their reachability to other routers, after obtaining routing information, we still need to find a way to construct the routing table.

Read more »

Introduction to Microservices

Monolithic application

The core of an application is business logic, which is implemented by modules that define services, domain objects, and events. Around the core is an adapter that interfaces with the outside world. Examples of adapters include database access components, messaging components that generate and consume messages, and web components that expose APIs or implement UIs.

Despite the architecture of logical Modularization, the application is packaged and deployed as a whole. The actual format depends on the language and framework of the application. For example, many Java applications are packaged as WAR files and deployed on application servers such as Tomcat or Jetty. Other Java applications are packaged as standalone executable JARs.

Successful applications have a habit of growing large over time. During each sprint, the development team implements more stories, which of course means adding many lines of code. In a few years, small, simple applications will become behemoths.

Read more »

IP Address

Two-level IP

The initial IP Address is composed of two parts, namely the network number and the host number. Different network numbers specify the network segment to which the IP belongs. It marks the network to which the host or router is connected. Each network number is unique in the entire Internet. The host number marks the host or router, and each host number is unique in the network number to which it belongs. So each IP is unique in the Internet.

This type of IP Address is called a two-level IP.

IP Address = {< network number >, < host number >}

Read more »

Echarts is a tool provided by Baidu for quickly drawing charts on the web. It draws charts in canvas through js, so as long as your project can support js, you can use echarts.

Echarts has a rich and detailed doc that allows us to customize the chart style we like. But this blog is mainly about how to use v-charts in vue projects.

Read more »

In recent days, I encountered a requirement, that is, when the project starts, I need to dynamically generate some code and introduce the generated code. At the beginning, my approach was to write the generated code into a file, then require these files, and then succeed. Then delete the file. After doing it, I found out that these files are not necessary to create, can they be directly imported from memory, which reduces the number of files io twice, and require is actually reading the file into memory and then parsing it, so from There is also a theoretical possibility of direct introduction in memory.

Read more »

Today, I need to use the tansaction of mongodb in my work, so I consulted various materials and stepped on a lot of pits. Here is a summary.

Read more »
0%