zoukankan      html  css  js  c++  java
  • 左耳听风-ARTS-第3周(2019/4/7-2019/4/13)

    Algorithm

    本周的算法题是按顺序合并两个已排序的链表(https://leetcode.com/problems/merge-two-sorted-lists/)。和归并排序的合并已排序数组的过程类似。

    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
            ListNode left = l1;
            ListNode right = l2;
    
            ListNode head = null;
            ListNode node = null;
    
            while (left != null && right != null) {
                if (left.val <= right.val) {
                    if (node == null) {
                        node = new ListNode(left.val);
                        head = node;
                    } else {
                        node.next = new ListNode(left.val);
                        node = node.next;
                    }
                    left = left.next;
                } else {
                    if (node == null) {
                        node = new ListNode(right.val);
                        head = node;
                    } else {
                        node.next = new ListNode(right.val);
                        node = node.next;
                    }
                    right = right.next;
                }
            }
    
            while (left != null) {
                if (node == null) {
                    node = new ListNode(left.val);
                    head = node;
                } else {
                    node.next = new ListNode(left.val);
                    node = node.next;
                }
                left = left.next;
            }
    
            while (right != null) {
                if (node == null) {
                    node = new ListNode(right.val);
                    head = node;
                } else {
                    node.next = new ListNode(right.val);
                    node = node.next;
                }
                right = right.next;
            }
            return head;
        }

    Reading

    这篇文章名是《Act with Prudence》(https://97-things-every-x-should-know.gitbooks.io/97-things-every-programmer-should-know/content/en/thing_01/),翻译过来时谨慎行事。文章主要讨论了技术债务这个问题。当在工作遇到必须在“正确的做”和“快速的做”这两种决策中选择时,我们往往倾向于“快速的做”,然后有时间再回来改,这时就埋下了技术债务。技术债务就像贷款,拖的时间越长,利息就越大。对于编程来说,结果可能最终导致代码难以维护。更糟的情况时,由于时间紧,需要在这些技术债务上再添加新的功能,到最后再回过头来偿还技术债务,可以说是灾难性的。这是像我这样的新手不知道,也意识不到的,需要特别注意。有了技术债务,要尽快偿还。

    Tip

    这周在看Spring cloud Netflix Zuul的源码时,发现Spring Cloud Netflix的内部添加了很多Filter,完成了主要的处理。直接读这些Filter的代码是枯燥的,就想看看真正的请求过来时,它怎么处理。一开始采用的笨办法是把要看的Filter源码复制出来,放在本地的Filter路径中看打印日志,弄了半天,才想起Debug更方便,明白自己很业余,这么好的工具已经忘了。

    Share

    这周工作中用到了Zuul网关,我研究了下,写了篇总结,https://www.cnblogs.com/minguo/p/10690433.html

  • 相关阅读:
    paip.代码生成器数据源格式最佳实践
    paip.hibernate list 返回位null的解决
    paip.hibernate save 失败的解决
    paip.提升效率---提升绑定层次--form绑定取代field绑定
    paip.python NameError name 'xxx' is not defined
    paip.sqlite 管理最好的工具 SQLite Expert 最佳实践总结
    paip.输入法英文词库的处理 python 代码 o4
    paip.判断文件是否存在uapi python php java c#
    paip.截取字符串byLastDot方法总结uapi python java php c# 总结
    paip.python连接mysql最佳实践o4
  • 原文地址:https://www.cnblogs.com/minguo/p/10703937.html
Copyright © 2011-2022 走看看