学习日记day37

Day37_1127

专注时间:6H17min

每日任务:计算机网络50分钟( 66 分钟),搜广推90分钟~上不封顶+手撕目录里的算法(0),二刷hot100算法题2道(完成 2 道),刑法实务考试复习50分钟( 125min,最后一次课认真听了,真是好课啊,自己喜欢,而且不用打卡签到点名互动

学习内容: 如上

总结与心得: 专注时长破纪录,这就是周四的强度,主要是课上时间没浪费,但是REC学的还是特别少啊,没动力学他,不能这样,而且总是放到最后去学。晚上再复习刑法PPT吧,弄完别的就去REC。

《11.盛水最多的容器》

AC

python 复制代码
class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        i,j = 0,len(height)-1
        res = 0
        while i<j:
            h = min(height[i],height[j])
            res = max(res,h*(j-i))
            if height[i]<=height[j]:
                i+=1
            else:
                j-=1
        return res

超时:

python 复制代码
class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        n = len(height)
        res = 0
        for i in range(n):
            for j in range(i+1,n):
                h = min(height[i],height[j])
                res = max(res,h*(j-i))
        return res

《15.三数之和》

超时代码,暴力

python 复制代码
class Solution(object):
    def threeSum(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res = []
        n = len(nums)
        if n < 3:
            return res
        nums.sort()
        for i in range(n):
            if i>0 and nums[i]==nums[i-1]:
                continue
            for j in range(i+1,n):
                if j>i+1 and nums[j]==nums[j-1]:
                    continue
                for k in range(j+1,n):
                    if k>j+1 and nums[k]==nums[k-1]:
                        continue
                    if nums[i]+nums[j]+nums[k]==0:
                        short_res = []
                        short_res.append(nums[i])
                        short_res.append(nums[j])
                        short_res.append(nums[k])
                        res.append(short_res)
        return res
        

AC:

python 复制代码
class Solution(object):
    def threeSum(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        n = len(nums)
        if not nums or n<3:
            return []
        res = []
        nums.sort()
        for i in range(n):
            if nums[i]>0:
                return res
            if i>0 and nums[i]==nums[i-1]:
                continue
            l,r = i+1,n-1
            while l<r:
                if nums[i]+nums[l]+nums[r] == 0 :
                    res.append([nums[i],nums[l],nums[r]])
                    while l<r and nums[l]==nums[l+1]:
                        l+=1
                    while l<r and nums[r]==nums[r-1]:
                        r-=1
                    l+=1
                    r-=1
                elif nums[i]+nums[l]+nums[r]>0:
                    r-=1
                else:
                    l+=1
        return res
                
相关推荐
ASKED_201914 小时前
Langchain学习笔记一 -基础模块以及架构概览
笔记·学习·langchain
(❁´◡`❁)Jimmy(❁´◡`❁)15 小时前
Exgcd 学习笔记
笔记·学习·算法
云小逸17 小时前
【nmap源码学习】 Nmap网络扫描工具深度解析:从基础参数到核心扫描逻辑
网络·数据库·学习
盐焗西兰花19 小时前
鸿蒙学习实战之路-Reader Kit构建阅读器最佳实践
学习·华为·harmonyos
深蓝海拓19 小时前
PySide6从0开始学习的笔记(二十七) 日志管理
笔记·python·学习·pyqt
慎独41319 小时前
科学赋能,让孩子专注高效爱上学习
学习
LGL6030A20 小时前
Java学习历程26——线程安全
java·开发语言·学习
学历真的很重要20 小时前
【系统架构师】第二章 操作系统知识 - 第二部分:进程管理(详解版)
学习·职场和发展·系统架构·系统架构师
Nebula_g20 小时前
线程进阶: 无人机自动防空平台开发教程(更新)
java·开发语言·数据结构·学习·算法·无人机
星期五不见面21 小时前
机器人学习!(二)ROS2-节点(7)2026/02/03
学习