简介
本文罗列了一些编程语言中常用的知识点,目的是为了让大家在掌握基本语法后,更好地上手刷Leetcode。主要内容提纲挈领地介绍C++和Python语言中,内置的一些数据类型和结构,已经对应的方法。
C++语法篇
数据结构
基本类型
- char: 1 byte
- unsigned char: 1byte
- short: 2 bytes
- unsigned short: 2 bytes
- int: 4 bytes
- unsigned int: 4 bytes
- long: 8 bytes
- unsigned long: 8 bytes
- float: 4 bytes
- double: 8 bytes
标准库
- string
- set
- deque
- unordered_map
- map
算法
Python语法篇
用python做Leetcode题,除了基本的语法外,还需要熟练使用一些设计基本数据结构的模块
基本语法
数据结构
Python内置的数据类型与C++很不一样,可以按照构造的方式分成可变类型和不可变乐星两类
可变类型
- list
- dict
- set
不可变类型
- str
- int
- float
- tuple
- bool
常用模块
算法
collections
-
Counter
用于快速统计可迭代变量,每个单元对应的数量 -
defaultdict
-
deque