Day45_1208
专注时间:5h44min朝着8H努力吧
每日任务:1h=二刷2道力扣hot100(完成情况及时长: 2道30分钟 );【学习资源:PyTorch官方文档:https://docs.pytorch.ac.cn/tutorials/beginner/basics/intro.html】1.5h=PyTorch工程实操(完成情况及时长: ?? );1h=周志华机器学习(完成情况及时长: 78分钟 );【按照Claude的路线】1h=手撕机器学习算法(完成情况及时长: ?? );计算机网络45分钟(完成情况及时长: ?? )
学完机器学习,然后是深度学习、搜广推经典模型(也有很多要手撕的,见Claude生成的)。学完PyTorch,之后是Transformer与大模型架构(见Gemini3pro生成的阶段2)。学快一点,学完还要做搜广推的实战项目。准备一个GitHub Repo把所有手撕过的算法整理进去,这会是最好的复习资料。
必须熟记的API、最简洁的GPT实现、带注释的Transformer实现、推荐系统模型库(包含主流模型实现)还有"Let's build GPT"系列学习视频见Claude的第20页。
学习内容: 如上,规划出了新的学习路线。
总结与心得: 周二不用写算法题了。第一道算法题写一遍就过,没有任何DEBUG和报错,不知不觉变强了,如果坚持学pytorch和推荐系统,那么这些方面的能力一定也能变强的,加油。但是发现递归算法还是弱,明天把这次二刷用到递归解法的题目的递归都重做一遍。
《19.删除链表的倒数第N个结点》

python
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def removeNthFromEnd(self, head, n):
"""
:type head: Optional[ListNode]
:type n: int
:rtype: Optional[ListNode]
"""
#一遍就过,我变这么厉害啦?
#初始化时候fast指针先走n步。之后两个指针同时每次只走一步,但当fast.next = None时,需要删除slow所指的下一个指针(需要dummyhead),
dummyhead = ListNode(0)
dummyhead.next = head
fast,slow = dummyhead,dummyhead
while n:
fast = fast.next
n-=1
while fast and fast.next:
fast = fast.next
slow = slow.next
slow.next = slow.next.next
return dummyhead.next
《24.两两交换链表中的节点》
迭代法和递归法

python
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def swapPairs(self, head):
"""
:type head: Optional[ListNode]
:rtype: Optional[ListNode]
"""
#改了两句代码就通过了,无敌,现在链表变得好强,可能主要归功于草稿纸上手写吧
if not head or not head.next:
return head
dummyhead = ListNode(0)
dummyhead.next = head
pre = dummyhead
node1,node2 = dummyhead.next,dummyhead.next.next
while node1 and node1.next:
node2 = node1.next
node1.next = node2.next
node2.next = node1
pre.next = node2
pre = node1
node1 = node1.next
return dummyhead.next
python
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def swapPairs(self, head):
"""
:type head: Optional[ListNode]
:rtype: Optional[ListNode]
"""
#递归思考一下
#没节点或者只有一个节点
if not head or not head.next:
return head
newhead = head.next
#其余节点(第二个节点后面的节点)是 newhead.next,对它们进行递归
head.next=self.swapPairs(newhead.next)
newhead.next = head
return newhead