2025-06-04 lc59. Spiral Matrix II
date: 2025-06-04 name: aliases: tags: leetcode python 语法 date_last_edit: 2025-06-04 04:47 — 2025-06-04
date: 2025-06-04 name: aliases: tags:
— creation date: 2025-06-04 04:34 — modification date: 星期三 4日 六月 2025 04:47:25
59. Spiral Matrix II1 之前写过再打开忘光了, 真感觉这个题是纯背的, 还有剩下的印象就是两个回来的步骤限制上有除了条件外的判断 可能从 0 开始学这个题的话, 就是如何切割切割, 切到最小的子问题, 这样, 但是这个题还是从背的角度出发去学的, 类型非常固定
我感觉我已经回想不起来了, 下面的步骤是一边看答案一边写的
因为是背的, 那要背什么呢, 背点意识就行了, 什么是这题的意识, 就是在模拟转一圈的行为, 那么转的话, 肯定不是无限的旋转吧, 那么什么是限制呢, OK 行的限制来了, 我们有 4 个转弯的地方, OK, 那么其实我们就定义如何转弯就行了, 给转弯加上限制,
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
left, right, top, down = 0 ,n - 1, 0, n - 1
pic = [[0] * n for _ in range(n)]
一开始的初始化如上, OK, 这里为什么要这样写? 定义一个二维数组没什么问题, 这是答案, 那么因为有限制, 限制具体是什么呢? 所以我们也要定义
继续我们的变化的逻辑, 我们希望填入数, 所以我们接下来写一个 num = 1
, 所以有
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
left, right, top, down = 0 ,n - 1, 0, n - 1
pic = [[0] * n for _ in range(n)]
num = 1
继续, 因为我们已经知道有几个格子了, 然后要填入的数又是从 1 开始的, 那么我们的 while 循环的判断就呼之欲出了, 就是 while num <= n * n:
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
left, right, top, down = 0 ,n - 1, 0, n - 1
pic = [[0] * n for _ in range(n)]
num = 1
while num <= n * n:
# left to right
# top to down
# right to left
# down to top
return pic
思考: 有个很像的题是这个 54. Spiral Matrix
date: 2025-06-04 name: aliases: tags: leetcode python 语法 date_last_edit: 2025-06-04 04:47 — 2025-06-04
date: 2025-06-03 name: aliases: tags: leetcode python 双指针 date_last_edit: 2025-06-03 18:37 — 2025-06-03
date: 2025-06-03 name: aliases: tags: leetcode python BinarySearch date_last_edit: 2025-06-03 16:46 — 2025-06-03
date: 2025-06-04 name: aliases: tags: leetcode python 双指针 date_last_edit: 2025-06-04 00:31 — 2025-06-04
使用GPT辅助对话的思考
使用 GPT refine 了文章
好像写成一个的线代的内容了, 有很多未完待续的内容
Using LLMs to refine context through chaotic thinking, but I think GPT-4.5 (2025-04-22) is quite good.
The article contains mistakes and misunderstandings, as it is a record of my own incorrect notes rather than a proper summary document.
https://www.youtube.com/watch?v=EWvNQjAaOHw
记录签证准备材料的list
文章翻译, 阅读, 解读MTF曲线, 笔记总结 Preface
A record of some simple ideas.
UCLA online learning how to learn powerful mental tools to help you master tough subjects
虎头蛇尾…
A small concept in discrete mathematics
进度条…(2/8)
The article contains three proofs.
mainly talk about FM&PM in ELEC202 at Lec 7&8