ORID 7

作者: Wilbur_ | 来源:发表于2020-02-16 05:14 被阅读0次

    学习udemy1小时 √
    看一页head first java √
    刷两道 leetcode √

    Add Two Numbers

    题目是这样的:You are given two non-empty linked lits representing two non-negative integers. The digits are stored in revere order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

    这道题根本没思路,所以直接看的视频讲解,这个youtube讲的还不错
    https://www.youtube.com/watch?v=aM4Iv7eEr2o

    就感觉今天看的那道medium的题还是很有用的,至少思路对我很有帮助。头一次发现Listnode可以直接用来linked list。(我以为要自己写……)

    因为本身这个list已经reverse 了,所以直接相加就好。主要是把carry写好,然后在多出x位数字的情况也写好就可以了。

    Ternary

    Ternary 在java里面用到的地方很多,其实就是if then 这样,表现为“?:”,比如(x==3) ? y:3,意思就是,如果x等于3,那么把y设置成3。

    相关文章

      网友评论

          本文标题:ORID 7

          本文链接:https://www.haomeiwen.com/subject/zgysfhtx.html