学习日记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
                
相关推荐
一个天蝎座 白勺 程序猿2 分钟前
AI入门系列:AI入门者的困惑:常见术语解释与误区澄清
人工智能·学习·ai
不想学习\??!6 分钟前
USB-HID学习笔记
笔记·学习
可可西里_X_back11 分钟前
linux学习(一)- 环境安装
学习
LXXgalaxy12 分钟前
Vue3 列表数据流:从赋值入门到进阶(独立学习版)
javascript·vue.js·学习
码农的小菜园31 分钟前
提示工程学习笔记(一)
笔记·学习
四谎真好看33 分钟前
Redis学习笔记(高级篇3)
redis·笔记·学习·学习笔记
十三画者42 分钟前
【文献分享】TREE通过基于 Transformer 的图表示技术,在生物网络中对癌症基因进行可解释的识别学习
网络·学习·transformer
君义_noip44 分钟前
信息学奥赛一本通 4164:【GESP2512七级】学习小组 | 洛谷 P14922 [GESP202512 七级] 学习小组
学习·算法·动态规划·gesp·信息学奥赛
wubba lubba dub dub7501 小时前
第四十二周 学习周报
学习
星幻元宇VR1 小时前
VR科普学习一体机|让知识触手可及的沉浸式科普新方式
科技·学习·安全·生活·vr