Skip to content

Commit 3ac291d

Browse files
committed
update weekly contest 168
1 parent 7a34180 commit 3ac291d

File tree

12 files changed

+221
-207
lines changed

12 files changed

+221
-207
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 l
3131

3232
### Weekly Contest 169
3333

34-
- [1304. Find N Unique Integers Sum up to Zero](./posts/1304.md)
35-
- [1305. All Elements in Two Binary Search Trees](./posts/1305.md)
34+
- [1304. 和为零的N个唯一整数](./posts/1304.md)
35+
- [1305. 两棵二叉搜索树中的所有元素](./posts/1305.md)
3636
- [1306. 跳跃游戏 III](./posts/1306.md)
3737
- [1307. 口算难题](./posts/1307.md)
3838

3939
### Weekly Contest 168
4040

41-
- [1295. Find Numbers with Even Number of Digits](./posts/1295.md)
42-
- [1296. Divide Array in Sets of K Consecutive Numbers](./posts/1296.md)
43-
- [1297. Maximum Number of Occurrences of a Substring](./posts/1297.md)
44-
- [1298. Maximum Candies You Can Get from Boxes](./posts/1298.md)
41+
- [1295. 统计位数为偶数的数字](./posts/1295.md)
42+
- [1296. 划分数组为连续数字的集合](./posts/1296.md)
43+
- [1297. 子串的最大出现次数](./posts/1297.md)
44+
- [1298. 你能从盒子里获得的最大糖果数](./posts/1298.md)
4545

4646
## 主题分类
4747

posts/1295.md

+28-27
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
# 1295. Find Numbers with Even Number of Digits
1+
# 1295. 统计位数为偶数的数字
22

3-
Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 leetcode 题解
3+
Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 leetcode 周赛题解
44

5-
这里是第 168 期的第 1 题,也是题目列表中的第 1295 题 -- 『Find Numbers with Even Number of Digits
5+
这里是第 168 期的第 1 题,也是题目列表中的第 1295 题 -- 『统计位数为偶数的数字
66

77
## 题目描述
88

9-
Given an array `nums` of integers, return how many of them contain an even number of digits.
9+
给你一个整数数组 `nums`,请你返回其中位数为 **偶数** 的数字的个数。
1010

11-
Example 1:
11+
示例 1:
1212

1313
```shell
14-
Input: nums = [12,345,2,6,7896]
15-
Output: 2
16-
Explanation:
17-
12 contains 2 digits (even number of digits).
18-
345 contains 3 digits (odd number of digits).
19-
2 contains 1 digit (odd number of digits).
20-
6 contains 1 digit (odd number of digits).
21-
7896 contains 4 digits (even number of digits).
22-
Therefore only 12 and 7896 contain an even number of digits.
14+
输入:nums = [12,345,2,6,7896]
15+
输出:2
16+
解释:
17+
12 2 位数字(位数为偶数)
18+
345 3 位数字(位数为奇数)
19+
2 1 位数字(位数为奇数)
20+
6 1 位数字 位数为奇数)
21+
7896 4 位数字(位数为偶数)  
22+
因此只有 12 7896 是位数为偶数的数字
2323
```
2424

25-
Example 2:
25+
示例 2:
2626

2727
```shell
28-
Input: nums = [555,901,482,1771]
29-
Output: 1
30-
Explanation:
31-
Only 1771 contains an even number of digits.
28+
输入:nums = [555,901,482,1771]
29+
输出:1
30+
解释:
31+
只有 1771 是位数为偶数的数字。
3232
```
3333

34-
Constraints:
34+
提示:
3535

36-
```shell
37-
1 <= nums.length <= 500
38-
1 <= nums[i] <= 10^5
39-
```
36+
- `1 <= nums.length <= 500`
37+
- `1 <= nums[i] <= 10^5`
4038

4139
## 官方难度
4240

@@ -100,6 +98,9 @@ const findNumbers = nums => {
10098

10199
## 相关链接
102100

103-
- [Weekly Contest 168 的其他问题](https://github.com/poppinlp/leetcode#weekly-contest-168)
104-
- [本文在 leetcode 的 post](https://leetcode.com/problems/find-numbers-with-even-number-of-digits/discuss/458421/javascript-easy-to-understand-2-solutions)
105-
- [我的题解 repo](https://github.com/poppinlp/leetcode)
101+
- [Weekly Contest 168 题目列表](https://github.com/poppinlp/leetcode#weekly-contest-168)
102+
- [系列题解 repo](https://github.com/poppinlp/leetcode)
103+
- [我的 segmentfault 专栏](https://segmentfault.com/blog/zxzfbz)
104+
- [我的知乎专栏](https://zhuanlan.zhihu.com/zxzfbz)
105+
106+
![我的微信公众号:张小猪粉鼻子](../resources/qrcode_green.jpeg)

posts/1296.md

+30-29
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
1-
# 1296. Divide Array in Sets of K Consecutive Numbers
1+
# 1296. 划分数组为连续数字的集合
22

3-
Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 leetcode 题解
3+
Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 leetcode 周赛题解
44

5-
这里是第 168 期的第 2 题,也是题目列表中的第 1296 题 -- 『Divide Array in Sets of K Consecutive Numbers
5+
这里是第 168 期的第 2 题,也是题目列表中的第 1296 题 -- 『划分数组为连续数字的集合
66

77
## 题目描述
88

9-
Given an array of integers `nums` and a positive integer `k`, find whether it's possible to divide this array into sets of `k` consecutive numbers
10-
Return `True` if its possible otherwise return `False`.
9+
给你一个整数数组 `nums` 和一个正整数 `k`,请你判断是否可以把这个数组划分成一些由 `k` 个连续数字组成的集合。
10+
如果可以,请返回 `True`;否则,返回 `False`
1111

12-
Example 1:
12+
示例 1:
1313

1414
```shell
15-
Input: nums = [1,2,3,3,4,4,5,6], k = 4
16-
Output: true
17-
Explanation: Array can be divided into [1,2,3,4] and [3,4,5,6].
15+
输入:nums = [1,2,3,3,4,4,5,6], k = 4
16+
输出:true
17+
解释:数组可以分成 [1,2,3,4] [3,4,5,6]
1818
```
1919

20-
Example 2:
20+
示例 2:
2121

2222
```shell
23-
Input: nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3
24-
Output: true
25-
Explanation: Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].
23+
输入:nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3
24+
输出:true
25+
解释:数组可以分成 [1,2,3] , [2,3,4] , [3,4,5] [9,10,11]
2626
```
2727

28-
Example 3:
28+
示例 3:
2929

3030
```shell
31-
Input: nums = [3,3,2,2,1,1], k = 3
32-
Output: true
31+
输入:nums = [3,3,2,2,1,1], k = 3
32+
输出:true
3333
```
3434

35-
Example 4:
35+
示例 4:
3636

3737
```shell
38-
Input: nums = [1,2,3,4], k = 3
39-
Output: false
40-
Explanation: Each array should be divided in subarrays of size 3.
38+
输入:nums = [1,2,3,4], k = 3
39+
输出:false
40+
解释:数组不能分成几个大小为 3 的子数组。
4141
```
4242

43-
Constraints:
43+
提示:
4444

45-
```shell
46-
1 <= nums.length <= 10^5
47-
1 <= nums[i] <= 10^9
48-
1 <= k <= nums.length
49-
```
45+
- `1 <= nums.length <= 10^5`
46+
- `1 <= nums[i] <= 10^9`
47+
- `1 <= k <= nums.length`
5048

5149
## 官方难度
5250

@@ -129,6 +127,9 @@ const isPossibleDivide = (nums, k) => {
129127

130128
## 相关链接
131129

132-
- [Weekly Contest 168 的其他问题](https://github.com/poppinlp/leetcode#weekly-contest-168)
133-
- [本文在 leetcode 的 post](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/discuss/458533/javascript-easy-to-understand-greedy)
134-
- [我的题解 repo](https://github.com/poppinlp/leetcode)
130+
- [Weekly Contest 168 题目列表](https://github.com/poppinlp/leetcode#weekly-contest-168)
131+
- [系列题解 repo](https://github.com/poppinlp/leetcode)
132+
- [我的 segmentfault 专栏](https://segmentfault.com/blog/zxzfbz)
133+
- [我的知乎专栏](https://zhuanlan.zhihu.com/zxzfbz)
134+
135+
![我的微信公众号:张小猪粉鼻子](../resources/qrcode_green.jpeg)

posts/1297.md

+28-25
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
# 1297. Maximum Number of Occurrences of a Substring
1+
# 1297. 子串的最大出现次数
22

3-
Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 leetcode 题解
3+
Hi 大家好,我是张小猪。欢迎来到『宝宝也能看懂』系列之 leetcode 周赛题解
44

5-
这里是第 168 期的第 3 题,也是题目列表中的第 1297 题 -- 『Maximum Number of Occurrences of a Substring
5+
这里是第 168 期的第 3 题,也是题目列表中的第 1297 题 -- 『子串的最大出现次数
66

77
## 题目描述
88

9-
Given a string `s`, return the maximum number of ocurrences of __any__ substring under the following rules:
9+
给你一个字符串 `s`,请你返回满足以下条件且出现次数最大的 **任意** 子串的出现次数:
1010

11-
The number of unique characters in the substring must be less than or equal to `maxLetters`.
12-
The substring size must be between `minSize` and `maxSize` inclusive.
11+
- 子串中不同字母的数目必须小于等于 `maxLetters`
12+
- 子串的长度必须大于等于 `minSize` 且小于等于 `maxSize`
1313

14-
Example 1:
14+
示例 1:
1515

1616
```shell
17-
Input: s = "aababcaab", maxLetters = 2, minSize = 3, maxSize = 4
18-
Output: 2
19-
Explanation: Substring "aab" has 2 ocurrences in the original string.
20-
It satisfies the conditions, 2 unique letters and size 3 (between minSize and maxSize).
17+
输入:s = "aababcaab", maxLetters = 2, minSize = 3, maxSize = 4
18+
输出:2
19+
解释:子串 "aab" 在原字符串中出现了 2 次。
20+
它满足所有的要求:2 个不同的字母,长度为 3 (在 minSize maxSize 范围内)。
2121
```
2222

23-
Example 2:
23+
示例 2:
2424

2525
```shell
26-
Input: s = "aaaa", maxLetters = 1, minSize = 3, maxSize = 3
27-
Output: 2
28-
Explanation: Substring "aaa" occur 2 times in the string. It can overlap.
26+
输入:s = "aaaa", maxLetters = 1, minSize = 3, maxSize = 3
27+
输出:2
28+
解释:子串 "aaa" 在原字符串中出现了 2 次,且它们有重叠部分。
2929
```
3030

31-
Example 3:
31+
示例 3:
3232

3333
```shell
34-
Input: s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
35-
Output: 3
34+
输入:s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
35+
输出:3
3636
```
3737

38-
Example 4:
38+
示例 4:
3939

4040
```shell
41-
Input: s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
42-
Output: 0
41+
输入:s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
42+
输出:0
4343
```
4444

45-
Constraints:
45+
提示:
4646

4747
```shell
4848
1 <= s.length <= 10^5
@@ -126,6 +126,9 @@ const maxFreq = (s, maxLetters, minSize, maxSize) => {
126126

127127
## 相关链接
128128

129-
- [Weekly Contest 168 的其他问题](https://github.com/poppinlp/leetcode#weekly-contest-168)
130-
- [本文在 leetcode 的 post](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/discuss/458591/JavaScript-Easy-to-understand-O\(n\)-with-Bit)
131-
- [我的题解 repo](https://github.com/poppinlp/leetcode)
129+
- [Weekly Contest 168 题目列表](https://github.com/poppinlp/leetcode#weekly-contest-168)
130+
- [系列题解 repo](https://github.com/poppinlp/leetcode)
131+
- [我的 segmentfault 专栏](https://segmentfault.com/blog/zxzfbz)
132+
- [我的知乎专栏](https://zhuanlan.zhihu.com/zxzfbz)
133+
134+
![我的微信公众号:张小猪粉鼻子](../resources/qrcode_green.jpeg)

0 commit comments

Comments
 (0)