会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
月为暮
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
5
6
7
8
9
10
11
12
13
···
16
下一页
2020年7月14日
面试题16.11跳水板
摘要: from typing import List# 这道题比较容易,遍历一遍k + 1就好了,# 可以算出所有的结果,但是会有重复值,因此需要将重复值排除# 同时避免超市class Solution: def divingBoard(self, shorter: int, longer: int, k
阅读全文
posted @ 2020-07-14 15:42 月为暮
阅读(189)
评论(0)
推荐(0)
2020年7月13日
51N皇后
摘要: from typing import List# 八皇后问题,用递归的方法来写。class Solution: def solveNQueens(self, n: int) -> List[List[str]]: # 如果n < 1直接返回空列表 if n < 1:return [] # 定义变量用
阅读全文
posted @ 2020-07-13 19:51 月为暮
阅读(246)
评论(0)
推荐(0)
30串联所有单词的子串
摘要: from typing import Listclass Solution: def findSubstring(self, s: str, words: List[str]) -> List[int]: # 导入计数类 from collections import Counter # 如果s和w
阅读全文
posted @ 2020-07-13 19:15 月为暮
阅读(171)
评论(0)
推荐(0)
2020年7月6日
04寻找两个数组的中位数
摘要: from typing import Listclass Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: # 这样写可以不用判断两个数组和为奇数和偶数的情况 index1
阅读全文
posted @ 2020-07-06 10:34 月为暮
阅读(225)
评论(0)
推荐(0)
28实现strSTR()
摘要: class Solution: def strStr(self, haystack: str, needle: str) -> int: # 判断needle是否为NOne或者为空字符串 if not needle or len(needle) == 0: return 0 # 定义两个变量,用来接
阅读全文
posted @ 2020-07-06 09:55 月为暮
阅读(217)
评论(0)
推荐(0)
2020年7月4日
125验证回文串
摘要: # 利用双指针,一次遍历,求出结果class Solution: def isPalindrome(self, s: str) -> bool: # 定义变量,接收字符串的长度 length = len(s) # 长度小于等于1直接返回真 if length <= 1:return True # 定
阅读全文
posted @ 2020-07-04 21:02 月为暮
阅读(181)
评论(0)
推荐(0)
2020年7月3日
124,二叉树中的最大路径和
摘要: # Definition for a binary tree node.class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = Nonea = TreeNode(1)b = TreeNode(
阅读全文
posted @ 2020-07-03 20:24 月为暮
阅读(261)
评论(0)
推荐(0)
2020年7月2日
123买卖股票的最佳时机III
摘要: from typing import Listclass Solution: def maxProfit(self, prices: List[int]) -> int: length = len(prices) if length <= 1:return 0 dp=[ [[0,0,0],[0,0,
阅读全文
posted @ 2020-07-02 16:29 月为暮
阅读(305)
评论(0)
推荐(0)
02爬取豆瓣最受欢迎的250部电影
摘要: # 爬取豆瓣最受欢迎的250部电影,并写入Excel表格中import requests,xlwtfrom bs4 import BeautifulSoup# 请求豆瓣网站,获取网页源码def request_douban(url): try : # 请求url headers = {"User-A
阅读全文
posted @ 2020-07-02 13:40 月为暮
阅读(321)
评论(0)
推荐(0)
2020年7月1日
01爬取当当网500本五星好评书籍
摘要: # import requests,re,json# # 定义一个函数用来请求当当网的网页信息# def request_dangdang(url):# try:# # 使用get请求# response = requests.get(url)# # 判断返回的状态码是否为200# if respo
阅读全文
posted @ 2020-07-01 21:00 月为暮
阅读(432)
评论(0)
推荐(1)
上一页
1
···
5
6
7
8
9
10
11
12
13
···
16
下一页
公告