2021-07-05

笔记_极客时间——算法面试通关40讲-第一章 02-04

数据结构

Sorting
Link list
List
Spanning tree
Tree
Graph
Stack
Hashing

在这里插入图片描述

Data structure

Array
Stack/Queue
PriorityQueue
LinkedList
Queue/Priority queue
Tree/Binary Search Tree
HashTable
Disjoint Set
Trie
BloomFilter
LRU Cache

Algorithm

Greedy
Recursion/Backtrace
Traversal
Breadth-first/Depth-first search
Divide and Conquer
Dynamic Programming
Binary Search
Graph

学习三要素:创建模型,即使反馈,刻意练习。

切题四件套
  1. Clarification
  2. Possible solutions
    -compare(time/space)
    -optimal(加强)
  3. Coding(多写)
  4. Test cases

如何计算算法的复杂度

时间复杂度

Big O notation

  • O(1):Constant Complexity:Constant常数复杂度 eg: int n = 1000
  • O(log n):Logarithmic Complexity:对数复杂度
  • O(n):Linear Complexity:线性时间复杂度
  • O(n^2):N square Complexity 平方
  • O(n^3):N square Complexity立方
  • O(2^n):Exponential Growth 指数
  • O(n!):Factorial 阶乘

Recurion

def fib(n):
	if n == 0 or n ==1:
		return n
	return fib(n-1)+fib(n-2) #O(2^n)

master theorem在这里插入图片描述

空间复杂度
Deliberate practicing
  • 坚持、刻意练习
  • 练习缺陷、弱点地方
  • 不舒服、不爽、枯燥

LeetCode:https://leetcode.com/problemset/all/

class Solution: 
	def twoSum(self,nums,target): 
		hash_map=dict() 
		for i,x in enumerate(nums): 
		#enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中
			if target-x in hash_map: 
				return [i,hash_map[target-×]
			hash_map[x] = i
Feedback!!

参考

算法面试通关40讲 覃超

https://www.runoob.com/python/python-func-enumerate.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值