力扣前300题

题目 链接 知识点
1.【数组】的纯操作 1. 两数之和 - 力扣(LeetCode) (leetcode-cn.com) 两层循环
2.【链表】的纯操作 2. 两数相加 - 力扣(LeetCode) (leetcode-cn.com) 链表先变字符串,再变int,然后再变成str遍历后变成数组,最后再建链表
3.【字符串】的纯操作 3. 无重复字符的最长子串 - 力扣(LeetCode) (leetcode-cn.com) 字符串取索引,和数组一样.index(值)
4.【数组】的纯操作 4. 寻找两个正序数组的中位数 - 力扣(LeetCode) (leetcode-cn.com)

//表示整数相除,取左边的数。

/表示浮点数相除。

并且记住数组索引

5.
6.
7.【列表】【字符串】 7. 整数反转 - 力扣(LeetCode) (leetcode-cn.com)

字符串不能反转,.join()返回的是字符串类型,直接去掉前面的列表,

int可将字符串转换成整数型,

8.【字符串】【整数】 8. 字符串转换整数 (atoi) - 力扣(LeetCode) (leetcode-cn.com)

分类讨论

字符串去空格:s.strip()

字母转换成数字:ord(s)  'a'=97

9.【int】【字符串】

9. 回文数 - 力扣(LeetCode) (leetcode-cn.com) 借鉴7题思路
10
11
12.【哈希表】 12. 整数转罗马数字 - 力扣(LeetCode) (leetcode-cn.com)

字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。

key=lambda x: x[1]以值的顺序排序

13.【字典】 13. 罗马数字转整数 - 力扣(LeetCode) (leetcode-cn.com)

猜你喜欢

转载自blog.csdn.net/weixin_45823221/article/details/120182923