ARTS挑战,第二周

1、Algorithm

Add Two Numbers

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.

要求:给到两个非空链表,它们表示两个非负整数。数字以相反的顺序存储它们的每个节点都包含一位数字。将这两个数字相加并以链表的形式返回。

编写的代码 https://leetcode.com/submissions/detail/198280812/  

class Solution {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode firstNode = new ListNode(-1);
        ListNode resultNode = firstNode;
        int nextAddValue = 0, addValue = 0;
        if (l1 != null || l2 != null) {
            addValue = l1.val + l2.val;
            nextAddValue = addValue / 10;
            resultNode = new ListNode(addValue % 10);
            l1 = l1.next;
            l2 = l2.next;
            firstNode = resultNode;

            while (l1 != null || l2 != null || nextAddValue != 0) {
                addValue = nextAddValue;
                if (l1 != null){
                    addValue += l1.val;
                }
                if (l2 != null){
                    addValue += l2.val;
                }

                nextAddValue = addValue / 10;
                ListNode resNode = new ListNode(addValue % 10);
                resultNode.next = resNode;
                resultNode = resNode;

                if (l1 != null){
                    l1 = l1.next;
                }
                if (l2 != null){
                    l2 = l2.next;
                }
            }
        }
        return firstNode;
    }
}

思路:循环,存在的情况,两个链表长度不一样,和的长度不一样。

2、Review

阅读文章:https://medium.com/@bethanymarz/the-worst-questions-you-can-ask-your-future-employer-in-a-job-interview-a46ae24b65e3

点评:文章列举了关于在面试的最后一个环节“问面试官问题”的5个最糟糕的问题,以及为什么作者会这么认为这些问题很糟糕。在阅读这篇文章的过程中,最大的感受是国外表述、说话的思路,理解起来感觉很吃力。比如:

But as for the worst questions? Oh yeah, that part is easy.

And so, I give you my five least favorite questions to be asked in an interview, along with why I think they suck, and what you might ask instead.

3、Tip

  学习了jenkins并做了一个小demo。

 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。

 

4、share

  关于开发中插件管理的一些小技巧。作为java开发人员,平时我们在使用的过程中,肯定有接触过不少的插件,或者工具类,很多时候我们处理了这个问题之后,可能就没管了,当再次遇到同样的问题却依旧需要找很久的资料,这个是很不应该的。所以对于开发人员来说,希望自己建立一些自己的工具类,可以方便管理的工具类库。

  参考了网上的一些资料,常用的代码管理工具主要有下面几种:GitHub、SVN、VSS、ClearCase。

  就我自己来说,我喜欢将一些常用的工具类给放到GitHub上,这样方便自己查看和管理。

  

原文地址:https://www.cnblogs.com/dyh2025/p/10203315.html