Skip to content

Commit 70f10e4

Browse files
author
Ziming M
committed
original commit
1 parent 8b97c1a commit 70f10e4

6 files changed

+70
-5
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 「LeetCode-Python3习题集」使用说明
22

3-
[![HitCount](http://hits.dwyl.io/ML-ZimingMeng/https://githubcom/ML-ZimingMeng/LeetCode-Python3.svg)](http://hits.dwyl.io/ML-ZimingMeng/https://githubcom/ML-ZimingMeng/LeetCode-Python3) [![GitHub forks](https://img.shields.io/github/forks/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/network) [![GitHub stars](https://img.shields.io/github/stars/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/stargazers) [![GitHub license](https://img.shields.io/github/license/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/blob/master/LICENSE)
3+
[![HitCount](http://hits.dwyl.io/ML-ZimingMeng/LeetCode-Python3.svg)](http://hits.dwyl.io/ML-ZimingMeng/LeetCode-Python3) [![GitHub forks](https://img.shields.io/github/forks/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/network) [![GitHub stars](https://img.shields.io/github/stars/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/stargazers) [![GitHub license](https://img.shields.io/github/license/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/blob/master/LICENSE)
44

55
[usEnglish Document](README_en.md) | 中文说明
66
## 简介
@@ -45,5 +45,4 @@
4545
## 结尾
4646
- 利用 Python 爬虫获取自己的 LeetCode 提交代码,并上传到 Github,请 [点击这里](https://github.com/ML-ZimingMeng/LeetCodeCN-Submissions-Crawler)
4747
- 为了带来最佳的阅读体验,本文遵循[「中文文案排版指北」](https://github.com/mzlogin/chinese-copywriting-guidelines)
48-
- 更多 Markdown 语法,请查看 [官方文档](https://www.markdownguide.org/basic-syntax/)
4948
- 感谢您阅读「LeetCode-Python3习题集」使用说明,祝您刷题愉快!

README_en.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# "LeetCode-Python3 Notebook" Problem Solutions
22

3-
[![HitCount](http://hits.dwyl.io/ML-ZimingMeng/https://githubcom/ML-ZimingMeng/LeetCode-Python3.svg)](http://hits.dwyl.io/ML-ZimingMeng/https://githubcom/ML-ZimingMeng/LeetCode-Python3) [![GitHub forks](https://img.shields.io/github/forks/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/network) [![GitHub stars](https://img.shields.io/github/stars/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/stargazers) [![GitHub license](https://img.shields.io/github/license/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/blob/master/LICENSE)
3+
[![HitCount](http://hits.dwyl.io/ML-ZimingMeng/LeetCode-Python3.svg)](http://hits.dwyl.io/ML-ZimingMeng/LeetCode-Python3) [![GitHub forks](https://img.shields.io/github/forks/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/network) [![GitHub stars](https://img.shields.io/github/stars/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/stargazers) [![GitHub license](https://img.shields.io/github/license/ML-ZimingMeng/LeetCode-Python3)](https://github.com/ML-ZimingMeng/LeetCode-Python3/blob/master/LICENSE)
44

55
usEnglish Document | [中文说明](README.md)
66
## Introduction
@@ -35,13 +35,12 @@ usEnglish Document | [中文说明](README.md)
3535
- [Design](/source/Clarification/Design)
3636
### 2. Classified by Order
3737
- [No.1 - No.1340](/source/All_Solutions)
38-
- [周赛 & 双周赛](/source/weeks)
38+
- [Weekly Contests](/source/weeks)
3939
> If it is helpful, your ✨Star will be my great honor.^_^
4040
## About
4141
- Blog:[ziming.xyz](https://www.ziming.xyz/)
4242
- My LeetCode:[Pumpkin🎃](https://leetcode-cn.com/u/ml-zimingmeng/)
4343
- Wechat: 🔰925730493
4444
- Get your own LeetCode submission code in one click and upload it to Github, [click here](https://github.com/ML-ZimingMeng/LeetCodeCN-Submissions-Crawler).
4545
- In order to bring the best reading experience, this article follows[「中文文案排版指北」](https://github.com/mzlogin/chinese-copywriting-guidelines).
46-
- For more Markdown syntax, please see [Official Documentation](https://www.markdownguide.org/basic-syntax/).
4746
- Thank you for reading the "LeetCode-Python3 Problem Solutions" instruction manual, and I wish you a happy reading!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def kWeakestRows(self, mat: List[List[int]], k: int) -> List[int]:
3+
dic = {}
4+
for i in range(len(mat)):
5+
dic[i] = mat[i].count(1)
6+
sort_dic = sorted(dic.items(),key = lambda x:x[1])
7+
res = []
8+
i = 0
9+
for key,value in sort_dic:
10+
res.append(key)
11+
i += 1
12+
if i == k:
13+
break
14+
return res
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def minSetSize(self, arr: List[int]) -> int:
3+
from collections import Counter
4+
n = len(arr)
5+
dic = Counter(arr)
6+
sorted_dic = sorted(dic.items(),key = lambda x:x[1],reverse = True)
7+
ans = 0
8+
for num, count in sorted_dic:
9+
n -= count
10+
ans += 1
11+
if n <= len(arr) / 2:
12+
break
13+
return ans
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode:
3+
# def __init__(self, x):
4+
# self.val = x
5+
# self.left = None
6+
# self.right = None
7+
8+
class Solution:
9+
def maxProduct(self, root: TreeNode) -> int:
10+
def getSum(root):
11+
if not root:
12+
return 0
13+
ret = getSum(root.left) + getSum(root.right) + root.val
14+
hashmap[root] = ret
15+
return ret
16+
hashmap = {}
17+
totalSum = getSum(root)
18+
ans = 0
19+
for k in hashmap:
20+
ans = max(ans,(totalSum - hashmap[k]) * hashmap[k])
21+
return ans % (10**9+7)

source/weeks/5331.跳跃游戏Ⅴ.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution:
2+
def maxJumps(self, arr: List[int], d: int) -> int:
3+
D = {}
4+
l = len(arr)
5+
def P(n):
6+
if n in D:
7+
return D[n]
8+
t = 1
9+
for i in range(1,d+1):
10+
if n + i >= l or arr[n] <= arr[n + i]:
11+
break
12+
t = max(t, 1+ P(n + i))
13+
for i in range(1, d + 1):
14+
if n - i < 0 or arr[n] <= arr[n - i]:
15+
break
16+
t = max(t, 1 + P(n - i))
17+
D[n] = t
18+
return t
19+
return max(P(i) for i in range(l))

0 commit comments

Comments
 (0)