美文网首页云莉的技术专题
训练准备和复杂度分析

训练准备和复杂度分析

作者: 云莉6 | 来源:发表于2020-03-04 00:24 被阅读0次

训练环境设置- 工欲善其事,必先利其器

电脑设置

Code Style

Java、Python…

  • Google code style

  • Facebook

  • Airbnb

LeetCode

指法和小操作

  • home, end (行头、行尾)

  • Word 单词、选单词、选整行

  • IDE 的自动补全

  • Top tips for <IDE-name>

自顶向下的编程方式

时间复杂度、空间复杂度

Big O notation

O(1): Constant Complexity 常数复杂度

O(log n): Logarithmic Complexity 对数复杂度

  • for (int i = 1; i < n; I = i * 2) { }

O(n): Linear Complexity 线性时间复杂度

  • for (int i = 1; i <= n; I = i++) { }

O(n^2): N square Complexity 平方

  • for (int i = 1; i <= n; I = i++) {
    for (int j = 1; j <= n; j++) {
    }
    }

O(n^3): N square Complexity 立方

O(2^n): Exponential Growth 指数

  • int fib(int n) {
    If (n <= 2) return n;
    Return fib(n - 1) + fib(n - 2);
    }

O(n!): Factorial 阶乘

时间复杂度曲线

image.png

相关文章

网友评论

    本文标题:训练准备和复杂度分析

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