ARTS Week 4

Algorithm

This week’s LeetCode problem is 206. Reverse Linked List

Description: Given the head of a singly linked list, reverse the list, and return the reversed list. For example, head = [1,2,3,4,5], the result is [5,4,3,2,1].

Solution Idea: original linked list is prev->curr, after reversing, it will become curr->prev.

Accepted Code

class Solution {
public ListNode reverseList(ListNode head) {
ListNode prev = null;
ListNode curr = head;
while (curr != null) {
ListNode next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
return prev;
}
}

Review

This week’s Review is for the following article: GIT PURR! Git Commands Explained with Cats!

The author’s hand-drawn cat firgures shows common operations in git, including git pull, git merge & git rebase, git push, and git cherry-pick & git log.

These figures are as follows.(Following the CC-BY-SA by Tomomi lmura)

Tip

Although the database provides multiple time and date types, we can actually get the correct local time based on the time zone information as long as we have the moment (Instant). So the best way is to use the long type for storage, so use the BIGINT type in the database.

Share

This is the 4th ARTS, but I found that I had unknowingly dug a few potholes, so I need to make up for the outstanding account during the holidays. The reason why I failed to stop writing ARTS was that after a certain delay in stopping the update, the later I dragged more and more, and the final result was that I couldn’t afford to write anymore, which led to stopping the update :(

--

--

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