ARTS Week 27

Algorithm

This week's LeetCode problem is 328. Odd Even Linked List

Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.

The first node is considered odd, and the second node is even, and so on.

Note that the relative order inside both the even and odd groups should remain as it was in the input.

You must solve the problem in O(1) extra space complexity and O(n) time complexity.

First, separate the odd and even head nodes, then traverse the links to find the odd node sub-linked list and the even node sub-linked list respectively, and finally create a new linked list header to connect the odd and even linked lists respectively.

Review

This week's Review is for the following article: What is port forwarding?

Port forwarding is to send network traffic from one port to another port on the same computer or on a different computer. After a specific port receives traffic, it will be processed by a specific network application, such as port 80 to handle website requests. This article explains how to do port forwarding:

  1. Port forwarding with your router, by setting the external port to 1234 and the internal port to 30000, this will forward port 1234 traffic to port 30000 on 10.0.1.2.
  2. Port forwarding with a firewall, you need to use the firewall-cmd command to forward traffic on the server:

To make changes permanent, add the --runtime-to-permanent option.

3. Beyond that, for example using IP forwarding or setting up a proxy.

Tip

How to call C language functions in Python? There is a ctypes library in Python, which can call functions in dynamic link libraries or shared libraries. Because C language supports function overloading, in order to avoid conflicts in binary, extern is required for modification. Here is an example:

Compile the above code into a shared library using the following compile command:

The code for Python to call the shared library is as follows:

The Python test code is as follows:

The results are as follows:

Share

Life has gradually returned to the right track. In the past week, I have basically gone out for a brisk walk or run every day to exercise, and I feel that no matter what the situation is, the body will always come first.

The Python test code is as follows:

The results are as follows:

Share

Life has gradually returned to the right track. In the past week, I have basically gone out for a brisk walk or run every day to exercise, and I feel that no matter what the situation is, the body will always come first.

--

--

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
KeepNewbie_yan

KeepNewbie_yan

5 Followers

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