bai-python-hwc 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bai_python_hwc/__init__.py +46 -0
- bai_python_hwc/answers/hwc101.py +38 -0
- bai_python_hwc/answers/hwc103.py +52 -0
- bai_python_hwc/answers/hwc104.py +45 -0
- bai_python_hwc/answers/hwc105.py +45 -0
- bai_python_hwc/answers/hwc106.py +56 -0
- bai_python_hwc/answers/hwc107.py +49 -0
- bai_python_hwc/answers/hwc108.py +45 -0
- bai_python_hwc/answers/hwc109.py +50 -0
- bai_python_hwc/answers/hwc110.py +42 -0
- bai_python_hwc/answers/hwc111.py +47 -0
- bai_python_hwc/answers/hwc112.py +42 -0
- bai_python_hwc/answers/hwc113.py +58 -0
- bai_python_hwc/answers/hwc114.py +58 -0
- bai_python_hwc/answers/hwc115.py +38 -0
- bai_python_hwc/answers/hwc116.py +44 -0
- bai_python_hwc/answers/hwc117.py +46 -0
- bai_python_hwc/answers/hwc118.py +47 -0
- bai_python_hwc/answers/hwc119.py +44 -0
- bai_python_hwc/answers/hwc120.py +41 -0
- bai_python_hwc/answers/hwc121.py +50 -0
- bai_python_hwc/answers/hwc122.py +54 -0
- bai_python_hwc/answers/hwc123.py +43 -0
- bai_python_hwc/answers/hwc124.py +41 -0
- bai_python_hwc/answers/hwc125.py +52 -0
- bai_python_hwc/answers/hwc126.py +40 -0
- bai_python_hwc/answers/hwc127.py +41 -0
- bai_python_hwc/answers/hwc128.py +39 -0
- bai_python_hwc/answers/hwc130.py +46 -0
- bai_python_hwc/answers/hwc131.py +46 -0
- bai_python_hwc/answers/hwc132.py +38 -0
- bai_python_hwc/answers/hwc133.py +61 -0
- bai_python_hwc/answers/hwc134.py +45 -0
- bai_python_hwc/answers/hwc135.py +49 -0
- bai_python_hwc/answers/hwc136.py +43 -0
- bai_python_hwc/answers/hwc201.py +47 -0
- bai_python_hwc/answers/hwc202.py +47 -0
- bai_python_hwc/answers/hwc203.py +48 -0
- bai_python_hwc/answers/hwc204.py +61 -0
- bai_python_hwc/answers/hwc205.py +56 -0
- bai_python_hwc/answers/hwc206.py +53 -0
- bai_python_hwc/answers/hwc207.py +43 -0
- bai_python_hwc/answers/hwc208.py +57 -0
- bai_python_hwc/answers/hwc209.py +42 -0
- bai_python_hwc/answers/hwc210.py +46 -0
- bai_python_hwc/answers/hwc211.py +62 -0
- bai_python_hwc/answers/hwc212.py +58 -0
- bai_python_hwc/answers/hwc213.py +54 -0
- bai_python_hwc/answers/hwc214.py +55 -0
- bai_python_hwc/answers/hwc215.py +53 -0
- bai_python_hwc/answers/hwc216.py +50 -0
- bai_python_hwc/answers/hwc217.py +38 -0
- bai_python_hwc/answers/hwc218.py +44 -0
- bai_python_hwc/answers/hwc219.py +49 -0
- bai_python_hwc/answers/hwc220.py +58 -0
- bai_python_hwc/answers/hwc221.py +49 -0
- bai_python_hwc/answers/hwc222.py +48 -0
- bai_python_hwc/answers/hwc223.py +39 -0
- bai_python_hwc/answers/hwc224.py +47 -0
- bai_python_hwc/answers/hwc225.py +50 -0
- bai_python_hwc/answers/hwc226.py +41 -0
- bai_python_hwc/answers/hwc227.py +40 -0
- bai_python_hwc/answers/hwc228.py +41 -0
- bai_python_hwc/answers/hwc229.py +51 -0
- bai_python_hwc/answers/hwc230.py +41 -0
- bai_python_hwc/answers/hwc231.py +39 -0
- bai_python_hwc/answers/hwc232.py +44 -0
- bai_python_hwc/answers/hwc233.py +49 -0
- bai_python_hwc/answers/hwc234.py +52 -0
- bai_python_hwc/answers/hwc235.py +45 -0
- bai_python_hwc/answers/hwc236.py +53 -0
- bai_python_hwc/answers/hwc237.py +56 -0
- bai_python_hwc/answers/hwc238.py +52 -0
- bai_python_hwc/answers/hwc239.py +60 -0
- bai_python_hwc/answers/hwc240.py +45 -0
- bai_python_hwc/answers/hwc241.py +48 -0
- bai_python_hwc/answers/hwc242.py +50 -0
- bai_python_hwc/answers/hwc243.py +61 -0
- bai_python_hwc/answers/hwc244.py +61 -0
- bai_python_hwc/answers/hwc245.py +47 -0
- bai_python_hwc/answers/hwc246.py +52 -0
- bai_python_hwc/answers/hwc247.py +76 -0
- bai_python_hwc/answers/hwc301.py +44 -0
- bai_python_hwc/answers/hwc302.py +53 -0
- bai_python_hwc/answers/hwc303.py +63 -0
- bai_python_hwc/answers/hwc304.py +56 -0
- bai_python_hwc/answers/hwc305.py +59 -0
- bai_python_hwc/answers/hwc306.py +60 -0
- bai_python_hwc/answers/hwc307.py +50 -0
- bai_python_hwc/answers/hwc308.py +59 -0
- bai_python_hwc/answers/hwc309.py +48 -0
- bai_python_hwc/answers/hwc310.py +38 -0
- bai_python_hwc/answers/hwc311.py +48 -0
- bai_python_hwc/answers/hwc312.py +49 -0
- bai_python_hwc/answers/hwc313.py +54 -0
- bai_python_hwc/answers/hwc314.py +49 -0
- bai_python_hwc/answers/hwc315.py +63 -0
- bai_python_hwc/answers/hwc316.py +65 -0
- bai_python_hwc/answers/hwc317.py +57 -0
- bai_python_hwc/answers/hwc318.py +55 -0
- bai_python_hwc/answers/hwc319.py +50 -0
- bai_python_hwc/answers/hwc320.py +84 -0
- bai_python_hwc/answers/hwc321.py +49 -0
- bai_python_hwc/answers/hwc322.py +49 -0
- bai_python_hwc/answers/hwc323.py +69 -0
- bai_python_hwc/answers/hwc324.py +66 -0
- bai_python_hwc/answers/hwc325.py +49 -0
- bai_python_hwc/answers/hwc326.py +53 -0
- bai_python_hwc/answers/hwc327.py +38 -0
- bai_python_hwc/answers/hwc328.py +50 -0
- bai_python_hwc/answers/hwc329.py +59 -0
- bai_python_hwc/answers/hwc330.py +45 -0
- bai_python_hwc/answers/hwc332.py +57 -0
- bai_python_hwc/answers/hwc401.py +50 -0
- bai_python_hwc/answers/hwc402.py +43 -0
- bai_python_hwc/answers/hwc403.py +73 -0
- bai_python_hwc/answers/hwc404.py +51 -0
- bai_python_hwc/answers/hwc405.py +62 -0
- bai_python_hwc/answers/hwc406.py +66 -0
- bai_python_hwc/answers/hwc407.py +49 -0
- bai_python_hwc/answers/hwc408.py +67 -0
- bai_python_hwc/answers/hwc409.py +51 -0
- bai_python_hwc/answers/hwc410.py +52 -0
- bai_python_hwc/answers/hwc411.py +57 -0
- bai_python_hwc/answers/hwc412.py +53 -0
- bai_python_hwc/answers/hwc413.py +65 -0
- bai_python_hwc/answers/hwc414.py +50 -0
- bai_python_hwc/answers/hwc415.py +61 -0
- bai_python_hwc/answers/hwc416.py +69 -0
- bai_python_hwc/answers/hwc418.py +47 -0
- bai_python_hwc/answers/hwc419.py +62 -0
- bai_python_hwc/answers/hwc421.py +51 -0
- bai_python_hwc/answers/hwc424.py +48 -0
- bai_python_hwc/answers/hwc501.py +63 -0
- bai_python_hwc/answers/hwc502.py +69 -0
- bai_python_hwc/answers/hwc503.py +75 -0
- bai_python_hwc/answers/hwc504.py +52 -0
- bai_python_hwc/answers/hwc505.py +63 -0
- bai_python_hwc/answers/hwc506.py +61 -0
- bai_python_hwc/answers/hwc508.py +60 -0
- bai_python_hwc/answers/hwc509.py +85 -0
- bai_python_hwc/answers/hwc510.py +56 -0
- bai_python_hwc/answers/hwc511.py +52 -0
- bai_python_hwc/answers/hwc513.py +63 -0
- bai_python_hwc/answers/hwc514.py +74 -0
- bai_python_hwc/answers/hwc515.py +83 -0
- bai_python_hwc/answers/hwc516.py +67 -0
- bai_python_hwc/answers/hwc517.py +46 -0
- bai_python_hwc/answers/hwc520.py +54 -0
- bai_python_hwc/answers/hwc526.py +58 -0
- bai_python_hwc/attachments/hwc424.pdf +0 -0
- bai_python_hwc/attachments/hwc501.pdf +0 -0
- bai_python_hwc/questions/hwc101.txt +17 -0
- bai_python_hwc/questions/hwc103.txt +27 -0
- bai_python_hwc/questions/hwc104.txt +22 -0
- bai_python_hwc/questions/hwc105.txt +23 -0
- bai_python_hwc/questions/hwc106.txt +26 -0
- bai_python_hwc/questions/hwc107.txt +29 -0
- bai_python_hwc/questions/hwc108.txt +18 -0
- bai_python_hwc/questions/hwc109.txt +24 -0
- bai_python_hwc/questions/hwc110.txt +16 -0
- bai_python_hwc/questions/hwc111.txt +25 -0
- bai_python_hwc/questions/hwc112.txt +13 -0
- bai_python_hwc/questions/hwc113.txt +28 -0
- bai_python_hwc/questions/hwc114.txt +35 -0
- bai_python_hwc/questions/hwc115.txt +15 -0
- bai_python_hwc/questions/hwc116.txt +13 -0
- bai_python_hwc/questions/hwc117.txt +14 -0
- bai_python_hwc/questions/hwc118.txt +25 -0
- bai_python_hwc/questions/hwc119.txt +18 -0
- bai_python_hwc/questions/hwc120.txt +23 -0
- bai_python_hwc/questions/hwc121.txt +26 -0
- bai_python_hwc/questions/hwc122.txt +21 -0
- bai_python_hwc/questions/hwc123.txt +21 -0
- bai_python_hwc/questions/hwc124.txt +19 -0
- bai_python_hwc/questions/hwc125.txt +31 -0
- bai_python_hwc/questions/hwc126.txt +18 -0
- bai_python_hwc/questions/hwc127.txt +17 -0
- bai_python_hwc/questions/hwc128.txt +14 -0
- bai_python_hwc/questions/hwc130.txt +23 -0
- bai_python_hwc/questions/hwc131.txt +19 -0
- bai_python_hwc/questions/hwc132.txt +16 -0
- bai_python_hwc/questions/hwc133.txt +39 -0
- bai_python_hwc/questions/hwc134.txt +22 -0
- bai_python_hwc/questions/hwc135.txt +29 -0
- bai_python_hwc/questions/hwc136.txt +20 -0
- bai_python_hwc/questions/hwc201.txt +20 -0
- bai_python_hwc/questions/hwc202.txt +25 -0
- bai_python_hwc/questions/hwc203.txt +26 -0
- bai_python_hwc/questions/hwc204.txt +32 -0
- bai_python_hwc/questions/hwc205.txt +28 -0
- bai_python_hwc/questions/hwc206.txt +28 -0
- bai_python_hwc/questions/hwc207.txt +16 -0
- bai_python_hwc/questions/hwc208.txt +27 -0
- bai_python_hwc/questions/hwc209.txt +15 -0
- bai_python_hwc/questions/hwc210.txt +28 -0
- bai_python_hwc/questions/hwc211.txt +35 -0
- bai_python_hwc/questions/hwc212.txt +29 -0
- bai_python_hwc/questions/hwc213.txt +27 -0
- bai_python_hwc/questions/hwc214.txt +27 -0
- bai_python_hwc/questions/hwc215.txt +28 -0
- bai_python_hwc/questions/hwc216.txt +22 -0
- bai_python_hwc/questions/hwc217.txt +17 -0
- bai_python_hwc/questions/hwc218.txt +18 -0
- bai_python_hwc/questions/hwc219.txt +22 -0
- bai_python_hwc/questions/hwc220.txt +28 -0
- bai_python_hwc/questions/hwc221.txt +18 -0
- bai_python_hwc/questions/hwc222.txt +20 -0
- bai_python_hwc/questions/hwc223.txt +18 -0
- bai_python_hwc/questions/hwc224.txt +23 -0
- bai_python_hwc/questions/hwc225.txt +26 -0
- bai_python_hwc/questions/hwc226.txt +18 -0
- bai_python_hwc/questions/hwc227.txt +15 -0
- bai_python_hwc/questions/hwc228.txt +16 -0
- bai_python_hwc/questions/hwc229.txt +20 -0
- bai_python_hwc/questions/hwc230.txt +18 -0
- bai_python_hwc/questions/hwc231.txt +13 -0
- bai_python_hwc/questions/hwc232.txt +19 -0
- bai_python_hwc/questions/hwc233.txt +21 -0
- bai_python_hwc/questions/hwc234.txt +27 -0
- bai_python_hwc/questions/hwc235.txt +18 -0
- bai_python_hwc/questions/hwc236.txt +23 -0
- bai_python_hwc/questions/hwc237.txt +28 -0
- bai_python_hwc/questions/hwc238.txt +25 -0
- bai_python_hwc/questions/hwc239.txt +28 -0
- bai_python_hwc/questions/hwc240.txt +21 -0
- bai_python_hwc/questions/hwc241.txt +25 -0
- bai_python_hwc/questions/hwc242.txt +23 -0
- bai_python_hwc/questions/hwc243.txt +35 -0
- bai_python_hwc/questions/hwc244.txt +25 -0
- bai_python_hwc/questions/hwc245.txt +24 -0
- bai_python_hwc/questions/hwc246.txt +28 -0
- bai_python_hwc/questions/hwc247.txt +51 -0
- bai_python_hwc/questions/hwc301.txt +23 -0
- bai_python_hwc/questions/hwc302.txt +26 -0
- bai_python_hwc/questions/hwc303.txt +32 -0
- bai_python_hwc/questions/hwc304.txt +32 -0
- bai_python_hwc/questions/hwc305.txt +31 -0
- bai_python_hwc/questions/hwc306.txt +31 -0
- bai_python_hwc/questions/hwc307.txt +29 -0
- bai_python_hwc/questions/hwc308.txt +30 -0
- bai_python_hwc/questions/hwc309.txt +25 -0
- bai_python_hwc/questions/hwc310.txt +15 -0
- bai_python_hwc/questions/hwc311.txt +23 -0
- bai_python_hwc/questions/hwc312.txt +19 -0
- bai_python_hwc/questions/hwc313.txt +26 -0
- bai_python_hwc/questions/hwc314.txt +27 -0
- bai_python_hwc/questions/hwc315.txt +21 -0
- bai_python_hwc/questions/hwc316.txt +36 -0
- bai_python_hwc/questions/hwc317.txt +28 -0
- bai_python_hwc/questions/hwc318.txt +27 -0
- bai_python_hwc/questions/hwc319.txt +26 -0
- bai_python_hwc/questions/hwc320.txt +42 -0
- bai_python_hwc/questions/hwc321.txt +27 -0
- bai_python_hwc/questions/hwc322.txt +26 -0
- bai_python_hwc/questions/hwc323.txt +24 -0
- bai_python_hwc/questions/hwc324.txt +40 -0
- bai_python_hwc/questions/hwc325.txt +21 -0
- bai_python_hwc/questions/hwc326.txt +25 -0
- bai_python_hwc/questions/hwc327.txt +16 -0
- bai_python_hwc/questions/hwc328.txt +15 -0
- bai_python_hwc/questions/hwc329.txt +26 -0
- bai_python_hwc/questions/hwc330.txt +27 -0
- bai_python_hwc/questions/hwc332.txt +26 -0
- bai_python_hwc/questions/hwc401.txt +25 -0
- bai_python_hwc/questions/hwc402.txt +24 -0
- bai_python_hwc/questions/hwc403.txt +37 -0
- bai_python_hwc/questions/hwc404.txt +23 -0
- bai_python_hwc/questions/hwc405.txt +29 -0
- bai_python_hwc/questions/hwc406.txt +34 -0
- bai_python_hwc/questions/hwc407.txt +24 -0
- bai_python_hwc/questions/hwc408.txt +28 -0
- bai_python_hwc/questions/hwc409.txt +25 -0
- bai_python_hwc/questions/hwc410.txt +23 -0
- bai_python_hwc/questions/hwc411.txt +34 -0
- bai_python_hwc/questions/hwc412.txt +29 -0
- bai_python_hwc/questions/hwc413.txt +28 -0
- bai_python_hwc/questions/hwc414.txt +27 -0
- bai_python_hwc/questions/hwc415.txt +27 -0
- bai_python_hwc/questions/hwc416.txt +36 -0
- bai_python_hwc/questions/hwc418.txt +25 -0
- bai_python_hwc/questions/hwc419.txt +28 -0
- bai_python_hwc/questions/hwc421.txt +23 -0
- bai_python_hwc/questions/hwc424.txt +20 -0
- bai_python_hwc/questions/hwc501.txt +23 -0
- bai_python_hwc/questions/hwc502.txt +41 -0
- bai_python_hwc/questions/hwc503.txt +36 -0
- bai_python_hwc/questions/hwc504.txt +18 -0
- bai_python_hwc/questions/hwc505.txt +25 -0
- bai_python_hwc/questions/hwc506.txt +32 -0
- bai_python_hwc/questions/hwc508.txt +24 -0
- bai_python_hwc/questions/hwc509.txt +42 -0
- bai_python_hwc/questions/hwc510.txt +25 -0
- bai_python_hwc/questions/hwc511.txt +23 -0
- bai_python_hwc/questions/hwc513.txt +25 -0
- bai_python_hwc/questions/hwc514.txt +35 -0
- bai_python_hwc/questions/hwc515.txt +46 -0
- bai_python_hwc/questions/hwc516.txt +26 -0
- bai_python_hwc/questions/hwc517.txt +20 -0
- bai_python_hwc/questions/hwc520.txt +27 -0
- bai_python_hwc/questions/hwc526.txt +36 -0
- bai_python_hwc-1.0.0.dist-info/METADATA +41 -0
- bai_python_hwc-1.0.0.dist-info/RECORD +305 -0
- bai_python_hwc-1.0.0.dist-info/WHEEL +5 -0
- bai_python_hwc-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目: 汉明距离总和
|
|
13
|
+
|
|
14
|
+
定义,两个整数的 汉明距离 指的是这两个数字的二进制数对应位不同的数量。
|
|
15
|
+
|
|
16
|
+
给你一个整数数组 nums,请你计算并返回 nums 中任意两个数之间 汉明距离的总和 。
|
|
17
|
+
|
|
18
|
+
提示:求4的二进制 bin(4) ,结果是字符串 '0b100'
|
|
19
|
+
|
|
20
|
+
示例 1:
|
|
21
|
+
|
|
22
|
+
输入:nums = [4,14,2]
|
|
23
|
+
输出:6
|
|
24
|
+
解释:在二进制表示中,4 表示为 0100 ,14 表示为 1110 ,2表示为 0010 。(这样表示是为了体现后四位之间关系)
|
|
25
|
+
所以答案为:
|
|
26
|
+
HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6
|
|
27
|
+
|
|
28
|
+
示例 2:
|
|
29
|
+
|
|
30
|
+
输入:nums = [4,14,4]
|
|
31
|
+
输出:4
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:前K个高频元素
|
|
13
|
+
|
|
14
|
+
给你一个整数数组 nums 和一个整数 k ,请你返回其中出现频率前 k 高的元素。
|
|
15
|
+
频率相同的元素,你可以按 任意顺序 加入list。
|
|
16
|
+
|
|
17
|
+
示例 1:
|
|
18
|
+
|
|
19
|
+
输入: nums = [1,1,1,2,2,3], k = 2
|
|
20
|
+
输出: [1,2]
|
|
21
|
+
|
|
22
|
+
示例 2:
|
|
23
|
+
|
|
24
|
+
输入: nums = [1], k = 1
|
|
25
|
+
输出: [1]
|
|
26
|
+
|
|
27
|
+
提示:
|
|
28
|
+
1.k 的取值范围是 [1, 数组中不相同的元素的个数]
|
|
29
|
+
2.当多个元素频率相同时,允许按任意顺序返回这些并列元素;测试数据会避免影响前 k 个集合的并列情况。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给你一个整数数组 nums ,找到其中最长严格递增子序列的长度。
|
|
14
|
+
子序列是由数组派生而来的序列,删除(或不删除)数组中的元素而不改变其余元素的顺序。例如,[3,6,2,7] 是数组 [0,3,1,6,2,2,7] 的子序列。
|
|
15
|
+
|
|
16
|
+
示例 1:
|
|
17
|
+
|
|
18
|
+
输入:nums = [10,9,2,5,3,7,101,18]
|
|
19
|
+
输出:4
|
|
20
|
+
解释:最长递增子序列是 [2,3,7,101],因此长度为 4 。
|
|
21
|
+
|
|
22
|
+
示例 2:
|
|
23
|
+
|
|
24
|
+
输入:nums = [0,1,0,3,2,3]
|
|
25
|
+
输出:4
|
|
26
|
+
|
|
27
|
+
示例 3:
|
|
28
|
+
|
|
29
|
+
输入:nums = [7,7,7,7,7,7,7]
|
|
30
|
+
输出:1
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目: 统计各位数字都不同的数字个数
|
|
13
|
+
|
|
14
|
+
提示:
|
|
15
|
+
给你一个整数 n ,统计并返回各位数字都不同的数字 x 的个数,其中 0 <= x < 10^n 。
|
|
16
|
+
|
|
17
|
+
示例 1:
|
|
18
|
+
|
|
19
|
+
输入:n = 2
|
|
20
|
+
输出:91
|
|
21
|
+
解释:答案应为除去 11、22、33、44、55、66、77、88、99 外,在 0 ≤ x < 100 范围内的所有数字。
|
|
22
|
+
|
|
23
|
+
示例 2:
|
|
24
|
+
输入:n = 0
|
|
25
|
+
输出:1
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
一个机器人位于一个 m x n 网格的左上角,机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角,
|
|
14
|
+
问总共有多少条不同的路径?,请在结果中只输出路径的个数,如3*4的网格,有10种路径,则输出: 10
|
|
15
|
+
分别求出m=3,n=4时的路径数,m=5,n=6时的路径数,m=6,n=7时的路径数。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
现有两个没有重复元素的数组nums1和nums2,其中nums1是nums2的子集。
|
|
14
|
+
|
|
15
|
+
请你找出nums1中每个元素在nums2中的下一个比其大的值。
|
|
16
|
+
|
|
17
|
+
nums1中数字x的下一个更大元素是指x在nums2中对应位置的右边的第一个比x大的元素。如果不存在,对应位置输出 -1 。
|
|
18
|
+
输入: nums1 = [4,1,2], nums2 = [1,3,4,2].
|
|
19
|
+
输出: [-1,3,-1]
|
|
20
|
+
解释:
|
|
21
|
+
对于nums1中的数字4 ,你无法在第二个数组中找到下一个更大的数字,因此输出 -1 。
|
|
22
|
+
对于num1中的数字1 ,第二个数组中数字1右边的下一个较大数字是 3 。
|
|
23
|
+
对于num1中的数字2 ,第二个数组中没有下一个更大的数字,因此输出 -1 。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:给定一个包括n 个整数的数组nums和一个目标值target。找出nums中的三个整数,使得它们的和与target最接近。
|
|
13
|
+
返回这三个数的和。假定每组输入只存在唯一答案。
|
|
14
|
+
|
|
15
|
+
示例:
|
|
16
|
+
|
|
17
|
+
输入:nums = [-1,2,1,-4], target = 1
|
|
18
|
+
输出:2
|
|
19
|
+
解释:与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:Z字形扫描
|
|
13
|
+
在图像编码的算法中,需要将一个给定的方形矩阵进行Z字形扫描(Zigzag Scan)。
|
|
14
|
+
|
|
15
|
+
例如,给定一个 n×n 的矩阵,沿 row+column 相等的对角线依次扫描;
|
|
16
|
+
对角线编号为偶数时从右上向左下输出,编号为奇数时从左下向右上输出。
|
|
17
|
+
输出列表包含 n×n 个整数,表示输入矩阵经过 Z 字形扫描后的结果。
|
|
18
|
+
|
|
19
|
+
示例:
|
|
20
|
+
输入:[[1,5,3,9],[3,7,5,6],[9,4,6,4],[7,3,1,3]]
|
|
21
|
+
|
|
22
|
+
1 5 3 9
|
|
23
|
+
3 7 5 6
|
|
24
|
+
9 4 6 4
|
|
25
|
+
7 3 1 3
|
|
26
|
+
输出:[1,5,3,9,7,3,9,5,4,7,3,6,6,4,1,3]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给定一个大小为 n 的整数数组,找出其中所有出现次数 超过三分之一(大于 ⌊n/3⌋,即 n 除以 3 向下取整)的元素。
|
|
14
|
+
|
|
15
|
+
进阶(可选):尝试只把数组遍历一遍、几乎不使用额外空间解决此问题。
|
|
16
|
+
|
|
17
|
+
示例 1:
|
|
18
|
+
输入: [3,2,3]
|
|
19
|
+
输出: [3]
|
|
20
|
+
|
|
21
|
+
示例 2:
|
|
22
|
+
输入: nums = [1]
|
|
23
|
+
输出: [1]
|
|
24
|
+
|
|
25
|
+
示例 3:
|
|
26
|
+
输入: [1,1,1,3,3,2,2,2]
|
|
27
|
+
输出: [1,2]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。
|
|
14
|
+
例如矩阵matrix = [ [ 1, 2, 3 ],
|
|
15
|
+
[ 4, 5, 6 ],
|
|
16
|
+
[ 7, 8, 9 ]
|
|
17
|
+
],返回的结果为[1, 2, 3, 6, 9, 8, 7, 4, 5]
|
|
18
|
+
请按照顺时针螺旋顺序 ,返回以下矩阵中的所有元素。
|
|
19
|
+
matrix1 = [[2,3,1,4],[4,5,1,5],[1,7,4,9],[4,7,2,1]]
|
|
20
|
+
matrix2 = [[4,6,8],[1,8,5],[5,1,7]]
|
|
21
|
+
matrix3 = [[23,17,54,66],[22,77,34,79]]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目《统计优美子数组》
|
|
13
|
+
|
|
14
|
+
问题描述
|
|
15
|
+
给你一个整数数组 nums 和一个整数 k。如果某个连续子数组中恰好有 k 个奇数数字,我们就认为这个子数组是「优美子数组」。
|
|
16
|
+
|
|
17
|
+
请返回这个数组中 「优美子数组」 的数目。
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
示例 1:
|
|
22
|
+
|
|
23
|
+
输入:nums = [1,1,2,1,1], k = 3
|
|
24
|
+
输出:2
|
|
25
|
+
解释:包含 3 个奇数的子数组是 [1,1,2,1] 和 [1,2,1,1] 。
|
|
26
|
+
|
|
27
|
+
示例 2:
|
|
28
|
+
|
|
29
|
+
输入:nums = [2,4,6], k = 1
|
|
30
|
+
输出:0
|
|
31
|
+
解释:数列中不包含任何奇数,所以不存在优美子数组。
|
|
32
|
+
|
|
33
|
+
示例 3:
|
|
34
|
+
|
|
35
|
+
输入:nums = [2,2,2,1,2,2,1,2,2,2], k = 2
|
|
36
|
+
输出:16
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:插入后的最大值
|
|
13
|
+
给你一个非常大的整数n和一个整数数字x,大整数n用一个字符串表示。n中每一位数字和数字x都处于闭区间 [1, 9] 中,且 n 可能表示一个 负数 。
|
|
14
|
+
你打算通过在n的十进制表示的任意位置插入x来最大化n的数值,但不能在负号的左边插入x。
|
|
15
|
+
例如,如果n = 73且x = 6,那么最佳方案是将6插入7和3之间,使n = 763。
|
|
16
|
+
如果n = -55且x = 2,那么最佳方案是将2插在第一个5之前,使n = -255。
|
|
17
|
+
返回插入操作后,用字符串表示的n的最大值。
|
|
18
|
+
|
|
19
|
+
示例:
|
|
20
|
+
输入:n = "99", x = 9
|
|
21
|
+
输出:"999"解释:不管在哪里插入 9 ,结果都是相同的。
|
|
22
|
+
|
|
23
|
+
提示:
|
|
24
|
+
1 <= n.length <= 105
|
|
25
|
+
1 <= x <= 9
|
|
26
|
+
n中每一位的数字都在闭区间[1, 9]中。
|
|
27
|
+
n代表一个有效的整数。
|
|
28
|
+
当n表示负数时,将会以字符'-'开始。
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
给你一个整数 n ,请你找出并返回第 n 个 丑数 。
|
|
14
|
+
|
|
15
|
+
丑数 就是只包含质因数 2、3、5 的正整数(换句话说:把它不断地除以 2、3、5,最后能正好除尽变成 1;注意 1 也算丑数)。
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
示例 1:
|
|
20
|
+
输入:n = 10
|
|
21
|
+
输出:12
|
|
22
|
+
解释:[1, 2, 3, 4, 5, 6, 8, 9, 10, 12] 是由前 10 个丑数组成的序列。
|
|
23
|
+
|
|
24
|
+
示例 2:
|
|
25
|
+
输入:n = 1
|
|
26
|
+
输出:1
|
|
27
|
+
解释:1 通常被视为丑数。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:字符串压缩。
|
|
13
|
+
利用字符重复出现的次数,编写一种方法,实现基本的字符串压缩功能。
|
|
14
|
+
比如,字符串aabcccccaaa会变为a2b1c5a3。若“压缩”后的字符串没有变短,则返回原先的字符串。
|
|
15
|
+
你可以假设字符串中只包含大小写英文字母(A-Z、a-z)。
|
|
16
|
+
|
|
17
|
+
示例1:
|
|
18
|
+
|
|
19
|
+
输入:"aabcccccaaa"
|
|
20
|
+
输出:"a2b1c5a3"
|
|
21
|
+
示例2:
|
|
22
|
+
|
|
23
|
+
输入:"abbccd"
|
|
24
|
+
输出:"abbccd"
|
|
25
|
+
解释:"abbccd"压缩后为"a1b2c2d1",比原字符串长度更长。
|
|
26
|
+
提示:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:(改编自计算机二级 Python 真题·综合应用题·字符串处理考点)
|
|
13
|
+
将一个 0~999 之间的非负整数 n 转换成英文单词字符串返回。
|
|
14
|
+
要求使用递归实现,参数为整数 n,返回一个英文单词字符串。
|
|
15
|
+
字典:0→zero, 1→one, 2→two, 3→three, 4→four, 5→five,
|
|
16
|
+
6→six, 7→seven, 8→eight, 9→nine, 10→ten,
|
|
17
|
+
11→eleven, 12→twelve, 13→thirteen, 14→fourteen,
|
|
18
|
+
15→fifteen, 16→sixteen, 17→seventeen, 18→eighteen, 19→nineteen,
|
|
19
|
+
20→twenty, 30→thirty, 40→forty, 50→fifty, 60→sixty, 70→seventy,
|
|
20
|
+
80→eighty, 90→ninety
|
|
21
|
+
|
|
22
|
+
提示:小于 20 直接查表;20-99 之间用 "tens + units";100-999 用
|
|
23
|
+
"X hundred [ + Y ]"(Y=0 时不加 and/Y)。
|
|
24
|
+
|
|
25
|
+
示例:
|
|
26
|
+
输入:n = 0
|
|
27
|
+
输出:"zero"
|
|
28
|
+
|
|
29
|
+
输入:n = 5
|
|
30
|
+
输出:"five"
|
|
31
|
+
|
|
32
|
+
输入:n = 23
|
|
33
|
+
输出:"twenty three"
|
|
34
|
+
|
|
35
|
+
输入:n = 100
|
|
36
|
+
输出:"one hundred"
|
|
37
|
+
|
|
38
|
+
输入:n = 115
|
|
39
|
+
输出:"one hundred fifteen"
|
|
40
|
+
|
|
41
|
+
输入:n = 999
|
|
42
|
+
输出:"nine hundred ninety nine"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给定一个整数数组 nums,其中恰好有两个元素只出现一次,其余所有元素均出现两次。
|
|
14
|
+
找出只出现一次的那两个元素。你可以按任意顺序返回答案。
|
|
15
|
+
|
|
16
|
+
示例 1:
|
|
17
|
+
输入:nums = [1,2,1,3,2,5]
|
|
18
|
+
输出:[3,5]
|
|
19
|
+
解释:[5, 3] 也是有效的答案。
|
|
20
|
+
|
|
21
|
+
示例 2:
|
|
22
|
+
输入:nums = [-1,0]
|
|
23
|
+
输出:[-1,0]
|
|
24
|
+
|
|
25
|
+
示例 3:
|
|
26
|
+
输入:nums = [0,1]
|
|
27
|
+
输出:[1,0]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
已知m*n矩阵matrix,将该矩阵顺时针旋转90度,并输出新矩阵。
|
|
14
|
+
示例:
|
|
15
|
+
matrix = [
|
|
16
|
+
[1, 2, 3],
|
|
17
|
+
[4, 5, 6],
|
|
18
|
+
[7, 8, 9]
|
|
19
|
+
]
|
|
20
|
+
正确输出结果为:
|
|
21
|
+
matrix_90 = [[7, 4, 1],[8, 5, 2],[9, 6, 3]]
|
|
22
|
+
|
|
23
|
+
请将以下矩阵顺时针旋转90度,并输出结果。
|
|
24
|
+
matrix1 = [[2,3,1,4],[4,5,1,5],[1,7,4,9],[4,7,2,1]]
|
|
25
|
+
matrix2 = [[4,6,8],[1,8,5],[5,1,7]]
|
|
26
|
+
matrix3 = [[23,17,54,66],[22,77,34,79]]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
给定整数数组 nums,判断 nums 中是否存在三个元素 a, b, c,使得 a + b + c = 0?
|
|
14
|
+
找出所有满足条件且不重复的三元组,返回一个列表,列表内每个元素是长度为 3 的 list。
|
|
15
|
+
三元组内部 a、b、c 按非降序排列;返回列表按字典序排列。
|
|
16
|
+
|
|
17
|
+
例如:
|
|
18
|
+
nums = [-1, 0, 1, 2, -1, -4, 4, -3, 7, -5]
|
|
19
|
+
result 形式如下:
|
|
20
|
+
[[-5, 1, 4], [-4, -3, 7], [-4, 0, 4], [-3, -1, 4], [-3, 1, 2], [-1, -1, 2], [-1, 0, 1]]
|
|
21
|
+
现有如下几个数组:
|
|
22
|
+
nums1 = [-1, 0, 1, 2, -1, -4, 3]
|
|
23
|
+
nums2 = [-2, 0, 1, 1, -1, 3, 4]
|
|
24
|
+
nums3 = [0, -1, 2, -3, 1, 2, 4]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:最长递增子序列
|
|
13
|
+
|
|
14
|
+
给你一个整数列表 arr,请找到其中最长递增子序列的长度。
|
|
15
|
+
|
|
16
|
+
子序列是由原列表派生而来的序列:删除(或不删除)列表中的一些元素,且不改变其余元素的相对顺序。
|
|
17
|
+
注意:子序列不要求元素在原列表中连续,但必须保持原有的先后顺序;本题中的"递增"指严格递增,即后一个元素必须严格大于前一个元素。
|
|
18
|
+
|
|
19
|
+
示例 1:
|
|
20
|
+
|
|
21
|
+
输入:arr = [10, 22, 9, 33, 21, 50, 41, 60, 80]
|
|
22
|
+
输出:6
|
|
23
|
+
解释:最长递增子序列是 [10, 22, 33, 50, 60, 80],长度为 6。
|
|
24
|
+
|
|
25
|
+
示例 2:
|
|
26
|
+
|
|
27
|
+
输入:arr = [3, 10, 2, 1, 20]
|
|
28
|
+
输出:3
|
|
29
|
+
解释:最长递增子序列是 [3, 10, 20],长度为 3。
|
|
30
|
+
|
|
31
|
+
示例 3:
|
|
32
|
+
|
|
33
|
+
输入:arr = [7, 7, 7, 7]
|
|
34
|
+
输出:1
|
|
35
|
+
解释:所有元素相等,不存在长度大于 1 的严格递增子序列。
|
|
36
|
+
|
|
37
|
+
提示:
|
|
38
|
+
如果 arr 为空列表,函数应返回 0。
|
|
39
|
+
|
|
40
|
+
请编写函数 TEST_DO_NOT_CHANGE(arr),其中 arr 是输入的整数列表,函数应该返回最长递增子序列的长度。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:跳跃游戏
|
|
13
|
+
非负整数数组 nums,你最初位于数组的 第一个下标 。数组中的每个元素代表你在该位置可以跳跃的最大长度。
|
|
14
|
+
判断你是否能够到达最后一个下标,如果可以,返回 True ;否则,返回 False 。
|
|
15
|
+
例如:nums = [3,2,1,0,4]
|
|
16
|
+
从第0个位置开始,即使可以跳跃3步至第3个位置,但第3个位置的值为0,因此不能再往后跳。
|
|
17
|
+
结果:无法到达最后一个位置,因此result返回值为:False。
|
|
18
|
+
现将以下几个数组进行跳跃游戏判断,判断你是否能够到达最后一个下标,如果可以,返回 True ;否则,返回 False 。
|
|
19
|
+
nums1 = [1,2,3,4,5]
|
|
20
|
+
nums2 = [2,3,1,1,4]
|
|
21
|
+
num3 = [1,1,1,1,0]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:(改编自计算机二级 Python 真题·综合应用题·枚举+素数考点)
|
|
13
|
+
在本题给定的输入范围内,按哥德巴赫猜想枚举可能的素数对;本题把该结论作为题设假定,
|
|
14
|
+
不要求证明“任何大于 2 的偶数都满足该性质”。
|
|
15
|
+
给定一个大于 2 的偶数 n,请找出所有满足 a + b = n 且 a <= b 的素数对 (a, b),
|
|
16
|
+
按 a 从小到大存入列表返回(每个元素是 (a, b))。
|
|
17
|
+
|
|
18
|
+
提示:先写一个 is_prime(x) 判断素数,再枚举 a 从 2 到 n//2。
|
|
19
|
+
|
|
20
|
+
示例:
|
|
21
|
+
输入:n = 10
|
|
22
|
+
输出:[(3, 7), (5, 5)]
|
|
23
|
+
|
|
24
|
+
输入:n = 20
|
|
25
|
+
输出:[(3, 17), (7, 13)]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
定义函数,求小于等于自然数 num 的所有完全数(Perfect number),存入 list 中并返回。
|
|
14
|
+
完全数是指所有真因子(即除了自身以外的约数)之和,恰好等于它本身。
|
|
15
|
+
例如:
|
|
16
|
+
第一个完全数是6,它有约数1、2、3、6,除去它本身6外,其余3个数相加,1+2+3=6。第二个完全数是28,它有约数1、2、4、7、14、28,除去它本身28外,其余5个数相加,1+2+4+7+14=28
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给你一个正整数 n ,生成一个包含 1 到 n² 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix 。
|
|
14
|
+
例如n=2,则结果为[[1,2],[4,3]]
|
|
15
|
+
请输出n=3、n=4、n=5时的结果。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
|
|
14
|
+
有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 到 65535 之间。
|
|
15
|
+
给你一个起点坐标 (sr, sc)(行、列)和一个新的颜色值 newColor,请你给这幅图像重新上色。
|
|
16
|
+
规则就像画图软件里的"油漆桶":从起点开始,把所有与它 上下左右相连、且颜色相同的格子都染成新颜色;
|
|
17
|
+
染色会一圈一圈向外扩散(新染的格子继续向四周扩散),直到没有可染的格子为止。
|
|
18
|
+
最后返回上色后的图像。
|
|
19
|
+
|
|
20
|
+
示例 1:
|
|
21
|
+
输入: image = [[1,1,1],[1,1,0],[1,0,1]], sr = 1, sc = 1, newColor = 2
|
|
22
|
+
输出: [[2,2,2],[2,2,0],[2,0,1]]
|
|
23
|
+
解释: 在图像的正中间,(坐标(sr,sc)=(1,1)),
|
|
24
|
+
在路径上所有符合条件的像素点的颜色都被更改成2。
|
|
25
|
+
注意,右下角的像素没有更改为2,
|
|
26
|
+
因为它不是在上下左右四个方向上与初始点相连的像素点。
|