Skip to main content

One post tagged with "数据结构和算法"

View All Tags

· 11 min read
LIU

时间复杂度

一般看的都是 O(1) ~ O(n^2) 范围,其它都是需要优化的

  • O(1)

    • if(i==1)
    • res = 100 1000、res = n 200
    • push(2)、pop()
    • map.set(1,1)、map.get(1)
    • 计算复杂度时,O(1)一般会被忽略
  • O(n)

    • for循环,while循环(不使用二分搜索)
  • O(log n)

    • 二分搜索