ARTS-Week001

Algorithm

本周Leetcode算法题:

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example:

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)

Output: 7 -> 0 -> 8

Explanation: 342 + 465 = 807.

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/add-two-numbers
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

解答详情 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**

- Definition for singly-linked list.
- public class ListNode {
- int val;
- ListNode next;
- ListNode(int x) { val = x; }
- }
*/
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode before = new ListNode(0);
ListNode now = before;

int carry = 0;
while(null != l1 || null != l2){
int x = null != l1 ? l1.val : 0;
int y = null != l2 ? l2.val : 0;

int sum = x + y + carry;

carry = sum / 10;
sum = sum % 10;

now.next = new ListNode(sum);

now = now.next;
if(null != l1){
l1 = l1.next;
}
if(null != l2){
l2 = l2.next;
}
}
if(carry > 0){
now.next = new ListNode(carry);
}
return before.next;
}
}

Review

https://www.baeldung.com/spring-5-reactive-websockets

博文讲述了响应式springboot后台使用websocket交互的方式

Tip

背景: 大数据组件数据质量管理工具Griffin本地Windows环境运行失败

现象: 程序报错–Failed to locate the winutils binary in the hadoop binary path

解决: https://blog.csdn.net/iamlihongwei/article/details/79876947

Sharing

整理了一些Linux操作文件的命令

https://blog.csdn.net/u011469281/article/details/95937347