ARTS第一周

Algorithm主要是为了编程训练和学习。每周至少做一个 leetcode 的算法题(先从Easy开始,然后再Medium,最后才Hard)。进行编程训练,如果不训练你看再多的算法书,你依然不会做算法题,看完书后,你需要训练。关于做Leetcode的的优势,你可以看一下我在coolshell上的文章 Leetcode 编程训练 - 酷 壳 - CoolShell。

Review:主要是为了学习英文,如果你的英文不行,你基本上无缘技术高手。所以,需要你阅读并点评至少一篇英文技术文章,我个人最喜欢去的地方是http://Medium.com(需要梯子)以及各个公司的技术blog,如Netflix的。

Tip:主要是为了总结和归纳你在是常工作中所遇到的知识点。学习至少一个技术技巧。你在工作中遇到的问题,踩过的坑,学习的点滴知识。

Share:主要是为了建立你的影响力,能够输出价值观。分享一篇有观点和思考的技术文章。

Algorithm

给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。

你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。

示例:

给定 nums = [2, 7, 11, 15], target = 9

因为 nums[0] + nums[1] = 2 + 7 = 9
所以返回 [0, 1]
class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        new_nums = [target - i for i in nums]
        for i,num in enumerate(new_nums):
            for j,_num in enumerate(nums):
                if num == _num and i != j:
                    return [i,j]
ARTS第一周_第1张图片
结果

逻辑上没有问题,但是看样子运算时间太长了。

第一题就翻车了,只能先看答案学习了,之后要加强算法相关知识的学习了。

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        hashmap = {}
        for index,num in enumerate(nums):
            another_num = target - num
            if another_num in hashmap:
                return [hashmap[another_num],index]
            hashmap[num] = index

发现这个答案执行简单的时间要84ms反而比我那个长,但是数量多起来,反而变得很快了。

ARTS第一周_第2张图片
参考答案

列表操作时间复杂度

ARTS第一周_第3张图片
列表操作时间复杂度

字典操作时间复杂度

ARTS第一周_第4张图片
字典操作时间复杂度

似乎在《流畅的Python》中看到字典的读取复杂度远比列表的低,所以可能正是由于这个原因,所以可以更快的计算出来吧。看来以后对性能要求高的时候要多用字典少用列表了。

Review

ARTS第一周_第5张图片
初学者的Docker介绍

A Beginner-Friendly Introduction to Containers, VMs and Docker

ARTS第一周_第6张图片
VM
ARTS第一周_第7张图片
containers

The one big difference between containers and VMs is that containers share the host system’s kernel with other containers.

Docker is an open-source project based on Linux containers. It uses Linux Kernel features like namespaces and control groups to create containers on top of an operating system.

Docker发展迅速的原因:

  • Ease of use
    • build once, run anywhere.
  • Speed
  • Docker Hub
    • app store for Docker images.
  • Modularity and Scalability
    • link containers together to create your application
ARTS第一周_第8张图片
Base

Docker基础

  • Docker Engine

  • Docker Client

  • Docker Daemon

  • Dockerfile

    • RUN apt-get y install some-package: to install a software package
    • EXPOSE 8000: to expose a port
    • ENV ANT_HOME /usr/local/apache-ant to pass an environment variable
  • Docker Image

  • Union File Systems

ARTS第一周_第9张图片
运行起来的镜像=容器

看完一篇英文文档真的是很痛苦。而且由于一直在翻译,所以感觉看一点忘了一点。

Tip

最近搭建了Gitlab服务器进行代码管理。

由于设备是Windows7,一开始使用的是Docker搭建的,但是Win7的Docker安装在一个虚拟机里面,发现每次一重启电脑,Docker中的gitlab中的数据就丢失了!虽然可以正常启动起来,但是数据丢失了,想使用-v进行数据持久化也没有用。所以最终的解决办法就是搭了一个虚拟机,在虚拟机上逐步的安装了一个Gitlab服务器。

Share

引入Gitlab,希望通过Code Review,团队一起提升代码质量。

使用Gitlab进行代码管理(Merge requests)

你可能感兴趣的:(ARTS第一周)