摘要: 和 238. Product of Array Except Self 计算除自己之外的乘积很像,先左侧遍历,再右侧遍历。 Hard不过如此。 class Solution: def candy(self, ratings: List[int]) -> int: # 1 n = len(rating 阅读全文
posted @ 2024-07-09 00:35 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 想到了提前判断和小于0的情况,懒得写,果然被阴间用例10万个加油站坑了。 class Solution: def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int: #1 n = len(gas) if n ==1: i 阅读全文
posted @ 2024-07-07 23:28 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 坑真的很多,首先要处理全零reduce没有值typeerror的问题。 class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: total=reduce(mul, nums) ret =[] if tota 阅读全文
posted @ 2024-07-07 19:31 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 竟然不需要import random,击败了5%的O(1)哈哈哈 class RandomizedSet: def __init__(self): self.data = [] def insert(self, val: int) -> bool: if val in self.data: retu 阅读全文
posted @ 2024-07-06 00:32 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 意外的简单。 class Solution: def hIndex(self, citations: List[int]) -> int: sorted_list = sorted(citations, reverse=True) ret = 0 for i,element in enumerate 阅读全文
posted @ 2024-07-05 00:46 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: docx类: import os from docx import Document from openpyxl import load_workbook def replace_string_in_docx(file_path, old_string, new_string): doc = Doc 阅读全文
posted @ 2024-07-04 14:37 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 有点意思,比想的要难。 错误思路 from typing import List from collections import Counter import time class Solution: def jump(self, nums: List[int]) -> int: max_reach 阅读全文
posted @ 2024-07-03 19:23 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 写了一个符和直觉的递归,时间超限了。 from typing import List import time class Solution: def canJump(self, nums: List[int]) -> bool: if len(nums) == 1: return True retu 阅读全文
posted @ 2024-07-03 14:36 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: medium是你的谎言. class Solution: def maxProfit(self, prices: List[int]) -> int: #1 if len(prices) == 1: return 0 #else max_profit = 0 min_price = prices[0 阅读全文
posted @ 2024-07-02 00:41 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 想清楚了确实算是简单题. class Solution: def maxProfit(self, prices: List[int]) -> int: #1 if len(prices) == 1: return 0 #else max_profit = 0 min_price = prices[0 阅读全文
posted @ 2024-07-02 00:28 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 无敌的切片他又来了。 class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ #0 if k == 阅读全文
posted @ 2024-07-01 16:22 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 排序,返回中值。 class Solution: def majorityElement(self, nums: List[int]) -> int: #always exists nums.sort() return nums[len(nums)//2] 阅读全文
posted @ 2024-06-30 14:16 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 原来leetcode使用Count也不需要import collections class Solution: def removeDuplicates(self, nums: List[int]) -> int: # len =0 if len(nums) == 0: return 0 # els 阅读全文
posted @ 2024-06-30 12:58 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 开刷Top Interview 150 class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nu 阅读全文
posted @ 2024-06-30 11:08 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 最近在测试WebSocket,写了一个服务端 # server.py import asyncio import websockets async def echo(websocket, path): async for message in websocket: print(f"Received 阅读全文
posted @ 2024-06-27 20:09 夜歌乘年少 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 对于给定list: 1、若最高位个数大于2 ,返回最高位 2、若最高位个数不大于2,返回最高位和次高位 example: '''[5,4,3,2,1] -> [5,4][5,5,4,4,4] -> [5,5][5,5,5,4,4] -> [5,5,5][5,5,5,5,5] -> [5,5,5,5, 阅读全文
posted @ 2020-10-24 17:12 夜歌乘年少 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 上一版PowerShell版本的莫名其妙的有些改不了:https://www.cnblogs.com/alfredsun/p/10124230.html 更新一个Python版本: 效果: 阅读全文
posted @ 2020-01-10 22:21 夜歌乘年少 阅读(1897) 评论(0) 推荐(0) 编辑
摘要: 查看任务管理器逻辑核心,CPU0全满,系统中断占用100%。 工具:https://www.thesycon.de/eng/latency_check.shtml 教程: https://answers.microsoft.com/zh-hans/windows/forum/windows_7-pe 阅读全文
posted @ 2019-10-13 12:25 夜歌乘年少 阅读(2841) 评论(0) 推荐(1) 编辑
摘要: 使用lsscsi查找要解挂载盘的ID: 拼接echo 1 > /sys/class/scsi_device/DISK_ID/device/delete;命令删除磁盘: echo 1 > /sys/class/scsi_device/32\:0\:3\:0/device/delete; echo 1 阅读全文
posted @ 2019-10-09 17:51 夜歌乘年少 阅读(1971) 评论(0) 推荐(0) 编辑
摘要: 1.找到种子:The.last.ride.伟大的愿望.2016.韩语中字.HR-HDTV.1024X576.x264-HJJL.ZiMuZu.torrent 2.安装aria2c: sudo apt install aria2 3.建立下载任务:aria2c -x 服务器连接数 -s 文件下载连接数 阅读全文
posted @ 2019-09-16 13:59 夜歌乘年少 阅读(1063) 评论(0) 推荐(0) 编辑
摘要: 只能想到求所有两两点的斜率 众数有两个而且出现次数相等 但是复杂度太高了 阅读全文
posted @ 2019-09-03 17:34 夜歌乘年少 阅读(508) 评论(0) 推荐(0) 编辑
摘要: https://www.youtube.com/watch?v=QlXlivz0yes https://www.youtube.com/watch?v=0XCSrzIWja8 阅读全文
posted @ 2019-09-01 00:15 夜歌乘年少 阅读(955) 评论(0) 推荐(0) 编辑
摘要: pre 生成关系森林 join 合并关系树 find 查找子节点 来源:https://blog.csdn.net/liujian20150808/article/details/50848646 阅读全文
posted @ 2019-08-26 17:15 夜歌乘年少 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 1.安装MySql: 2.配置MySQL: 检查服务: 连接数据库: sudo mysql -uroot -p 使用上面初始化的密码登录 3.使用SQL 创建数据库:CREATE database test; 连接数据库:use test; 创建数据表:create table testtable( 阅读全文
posted @ 2019-08-22 09:48 夜歌乘年少 阅读(295) 评论(0) 推荐(0) 编辑
摘要: Success Details Success Runtime: 36 ms, faster than 80.76% of Python3 online submissions for Implement strStr(). Memory Usage: 13.9 MB, less than 12.3 阅读全文
posted @ 2019-08-12 10:57 夜歌乘年少 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Success Details Success Runtime: 52 ms, faster than 8.08% of Python3 online submissions for Remove Element. Memory Usage: 13.8 MB, less than 6.06% of  阅读全文
posted @ 2019-08-12 10:22 夜歌乘年少 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 要求原位去重排序,返回nums的length并用nums的引用来检查排序,非常无聊的字符操作 不如来一发深拷贝吧~233 Success Details Runtime: 92 ms, faster than 90.98% of Python3 online submissions for Remo 阅读全文
posted @ 2019-08-09 14:35 夜歌乘年少 阅读(282) 评论(1) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-08-08 20:22 夜歌乘年少 阅读(2) 评论(1) 推荐(0) 编辑
摘要: 从这位大佬这里抄了解法2:https://www.cnblogs.com/grandyang/p/4441324.html 解法二: 我们也可以使用递归来做,我们用 head 记录每段的开始位置,cur 记录结束位置的下一个节点,然后我们调用 reverse 函数来将这段翻转,然后得到一个 new_ 阅读全文
posted @ 2019-08-08 16:56 夜歌乘年少 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 这题很烦 做完满脑子都是箭头。 这里head之后 和tail之前 不能用next这种形式来给next复制 会造成循环链表 tailNode.next = headNode.next # 4 next point to 2 tailprevNode.next = headNode # 3 next p 阅读全文
posted @ 2019-08-08 16:06 夜歌乘年少 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 在家瘫了半个月,虚弱时长2月半,又来水题了~ 内存感人,不过想不出来不用temp保存中间值的链表交换方法了。 Success Details Success Runtime: 40 ms, faster than 44.76% of Python3 online submissions for Sw 阅读全文
posted @ 2019-08-08 10:36 夜歌乘年少 阅读(199) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-08-07 15:10 夜歌乘年少 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Linux: pstree Windows: ProcessExplorer or PS script:https://gist.github.com/atifaziz/9390344 or 阅读全文
posted @ 2019-08-05 17:41 夜歌乘年少 阅读(617) 评论(0) 推荐(0) 编辑
摘要: https://docs.microsoft.com/zh-cn/windows/security/threat-protection/auditing/basic-audit-directory-service-access 阅读全文
posted @ 2019-08-01 16:44 夜歌乘年少 阅读(208) 评论(0) 推荐(0) 编辑
摘要: hd=default,vdbench=C:\vdbench50406,shell=vdbench hd=hd1,system=host1 hd=hd2,system=host2 hd=hd3,system=host3 hd=hd4,system=host4 fsd=default,openflags=directio fsd=fsd01,anchor=x:\hd1_fs1_64KB_1MB,d... 阅读全文
posted @ 2019-07-16 11:42 夜歌乘年少 阅读(569) 评论(0) 推荐(0) 编辑
摘要: 网卡: 可见 ETH0-4都是10的优先级。 配置网卡优先级: 查看: 阅读全文
posted @ 2019-07-15 11:00 夜歌乘年少 阅读(2165) 评论(0) 推荐(0) 编辑
摘要: 一般是内核更新失败,首先用旧内核开机,修复新内核版本: 查看内核列表: sudo dpkg --get-selections |grep linux-image linux 4.15.0-34 generic linux 4.15.0-54 generic 首先尝试修复内核: sudo dpkg - 阅读全文
posted @ 2019-07-10 09:52 夜歌乘年少 阅读(4647) 评论(0) 推荐(0) 编辑
摘要: https://fdc.nal.usda.gov/fdc-app.html#/?query=ndbNumber:11352 阅读全文
posted @ 2019-07-09 15:53 夜歌乘年少 阅读(246) 评论(0) 推荐(0) 编辑
摘要: result: 阅读全文
posted @ 2019-07-09 15:41 夜歌乘年少 阅读(553) 评论(0) 推荐(0) 编辑
摘要: gpedit.msc Computer Configuration - Administrative Templates - Windows Components - Remote Desktop Services - Remote Desktop Session Host - Connection 阅读全文
posted @ 2019-07-02 17:52 夜歌乘年少 阅读(504) 评论(0) 推荐(0) 编辑