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.
Files changed (305) hide show
  1. bai_python_hwc/__init__.py +46 -0
  2. bai_python_hwc/answers/hwc101.py +38 -0
  3. bai_python_hwc/answers/hwc103.py +52 -0
  4. bai_python_hwc/answers/hwc104.py +45 -0
  5. bai_python_hwc/answers/hwc105.py +45 -0
  6. bai_python_hwc/answers/hwc106.py +56 -0
  7. bai_python_hwc/answers/hwc107.py +49 -0
  8. bai_python_hwc/answers/hwc108.py +45 -0
  9. bai_python_hwc/answers/hwc109.py +50 -0
  10. bai_python_hwc/answers/hwc110.py +42 -0
  11. bai_python_hwc/answers/hwc111.py +47 -0
  12. bai_python_hwc/answers/hwc112.py +42 -0
  13. bai_python_hwc/answers/hwc113.py +58 -0
  14. bai_python_hwc/answers/hwc114.py +58 -0
  15. bai_python_hwc/answers/hwc115.py +38 -0
  16. bai_python_hwc/answers/hwc116.py +44 -0
  17. bai_python_hwc/answers/hwc117.py +46 -0
  18. bai_python_hwc/answers/hwc118.py +47 -0
  19. bai_python_hwc/answers/hwc119.py +44 -0
  20. bai_python_hwc/answers/hwc120.py +41 -0
  21. bai_python_hwc/answers/hwc121.py +50 -0
  22. bai_python_hwc/answers/hwc122.py +54 -0
  23. bai_python_hwc/answers/hwc123.py +43 -0
  24. bai_python_hwc/answers/hwc124.py +41 -0
  25. bai_python_hwc/answers/hwc125.py +52 -0
  26. bai_python_hwc/answers/hwc126.py +40 -0
  27. bai_python_hwc/answers/hwc127.py +41 -0
  28. bai_python_hwc/answers/hwc128.py +39 -0
  29. bai_python_hwc/answers/hwc130.py +46 -0
  30. bai_python_hwc/answers/hwc131.py +46 -0
  31. bai_python_hwc/answers/hwc132.py +38 -0
  32. bai_python_hwc/answers/hwc133.py +61 -0
  33. bai_python_hwc/answers/hwc134.py +45 -0
  34. bai_python_hwc/answers/hwc135.py +49 -0
  35. bai_python_hwc/answers/hwc136.py +43 -0
  36. bai_python_hwc/answers/hwc201.py +47 -0
  37. bai_python_hwc/answers/hwc202.py +47 -0
  38. bai_python_hwc/answers/hwc203.py +48 -0
  39. bai_python_hwc/answers/hwc204.py +61 -0
  40. bai_python_hwc/answers/hwc205.py +56 -0
  41. bai_python_hwc/answers/hwc206.py +53 -0
  42. bai_python_hwc/answers/hwc207.py +43 -0
  43. bai_python_hwc/answers/hwc208.py +57 -0
  44. bai_python_hwc/answers/hwc209.py +42 -0
  45. bai_python_hwc/answers/hwc210.py +46 -0
  46. bai_python_hwc/answers/hwc211.py +62 -0
  47. bai_python_hwc/answers/hwc212.py +58 -0
  48. bai_python_hwc/answers/hwc213.py +54 -0
  49. bai_python_hwc/answers/hwc214.py +55 -0
  50. bai_python_hwc/answers/hwc215.py +53 -0
  51. bai_python_hwc/answers/hwc216.py +50 -0
  52. bai_python_hwc/answers/hwc217.py +38 -0
  53. bai_python_hwc/answers/hwc218.py +44 -0
  54. bai_python_hwc/answers/hwc219.py +49 -0
  55. bai_python_hwc/answers/hwc220.py +58 -0
  56. bai_python_hwc/answers/hwc221.py +49 -0
  57. bai_python_hwc/answers/hwc222.py +48 -0
  58. bai_python_hwc/answers/hwc223.py +39 -0
  59. bai_python_hwc/answers/hwc224.py +47 -0
  60. bai_python_hwc/answers/hwc225.py +50 -0
  61. bai_python_hwc/answers/hwc226.py +41 -0
  62. bai_python_hwc/answers/hwc227.py +40 -0
  63. bai_python_hwc/answers/hwc228.py +41 -0
  64. bai_python_hwc/answers/hwc229.py +51 -0
  65. bai_python_hwc/answers/hwc230.py +41 -0
  66. bai_python_hwc/answers/hwc231.py +39 -0
  67. bai_python_hwc/answers/hwc232.py +44 -0
  68. bai_python_hwc/answers/hwc233.py +49 -0
  69. bai_python_hwc/answers/hwc234.py +52 -0
  70. bai_python_hwc/answers/hwc235.py +45 -0
  71. bai_python_hwc/answers/hwc236.py +53 -0
  72. bai_python_hwc/answers/hwc237.py +56 -0
  73. bai_python_hwc/answers/hwc238.py +52 -0
  74. bai_python_hwc/answers/hwc239.py +60 -0
  75. bai_python_hwc/answers/hwc240.py +45 -0
  76. bai_python_hwc/answers/hwc241.py +48 -0
  77. bai_python_hwc/answers/hwc242.py +50 -0
  78. bai_python_hwc/answers/hwc243.py +61 -0
  79. bai_python_hwc/answers/hwc244.py +61 -0
  80. bai_python_hwc/answers/hwc245.py +47 -0
  81. bai_python_hwc/answers/hwc246.py +52 -0
  82. bai_python_hwc/answers/hwc247.py +76 -0
  83. bai_python_hwc/answers/hwc301.py +44 -0
  84. bai_python_hwc/answers/hwc302.py +53 -0
  85. bai_python_hwc/answers/hwc303.py +63 -0
  86. bai_python_hwc/answers/hwc304.py +56 -0
  87. bai_python_hwc/answers/hwc305.py +59 -0
  88. bai_python_hwc/answers/hwc306.py +60 -0
  89. bai_python_hwc/answers/hwc307.py +50 -0
  90. bai_python_hwc/answers/hwc308.py +59 -0
  91. bai_python_hwc/answers/hwc309.py +48 -0
  92. bai_python_hwc/answers/hwc310.py +38 -0
  93. bai_python_hwc/answers/hwc311.py +48 -0
  94. bai_python_hwc/answers/hwc312.py +49 -0
  95. bai_python_hwc/answers/hwc313.py +54 -0
  96. bai_python_hwc/answers/hwc314.py +49 -0
  97. bai_python_hwc/answers/hwc315.py +63 -0
  98. bai_python_hwc/answers/hwc316.py +65 -0
  99. bai_python_hwc/answers/hwc317.py +57 -0
  100. bai_python_hwc/answers/hwc318.py +55 -0
  101. bai_python_hwc/answers/hwc319.py +50 -0
  102. bai_python_hwc/answers/hwc320.py +84 -0
  103. bai_python_hwc/answers/hwc321.py +49 -0
  104. bai_python_hwc/answers/hwc322.py +49 -0
  105. bai_python_hwc/answers/hwc323.py +69 -0
  106. bai_python_hwc/answers/hwc324.py +66 -0
  107. bai_python_hwc/answers/hwc325.py +49 -0
  108. bai_python_hwc/answers/hwc326.py +53 -0
  109. bai_python_hwc/answers/hwc327.py +38 -0
  110. bai_python_hwc/answers/hwc328.py +50 -0
  111. bai_python_hwc/answers/hwc329.py +59 -0
  112. bai_python_hwc/answers/hwc330.py +45 -0
  113. bai_python_hwc/answers/hwc332.py +57 -0
  114. bai_python_hwc/answers/hwc401.py +50 -0
  115. bai_python_hwc/answers/hwc402.py +43 -0
  116. bai_python_hwc/answers/hwc403.py +73 -0
  117. bai_python_hwc/answers/hwc404.py +51 -0
  118. bai_python_hwc/answers/hwc405.py +62 -0
  119. bai_python_hwc/answers/hwc406.py +66 -0
  120. bai_python_hwc/answers/hwc407.py +49 -0
  121. bai_python_hwc/answers/hwc408.py +67 -0
  122. bai_python_hwc/answers/hwc409.py +51 -0
  123. bai_python_hwc/answers/hwc410.py +52 -0
  124. bai_python_hwc/answers/hwc411.py +57 -0
  125. bai_python_hwc/answers/hwc412.py +53 -0
  126. bai_python_hwc/answers/hwc413.py +65 -0
  127. bai_python_hwc/answers/hwc414.py +50 -0
  128. bai_python_hwc/answers/hwc415.py +61 -0
  129. bai_python_hwc/answers/hwc416.py +69 -0
  130. bai_python_hwc/answers/hwc418.py +47 -0
  131. bai_python_hwc/answers/hwc419.py +62 -0
  132. bai_python_hwc/answers/hwc421.py +51 -0
  133. bai_python_hwc/answers/hwc424.py +48 -0
  134. bai_python_hwc/answers/hwc501.py +63 -0
  135. bai_python_hwc/answers/hwc502.py +69 -0
  136. bai_python_hwc/answers/hwc503.py +75 -0
  137. bai_python_hwc/answers/hwc504.py +52 -0
  138. bai_python_hwc/answers/hwc505.py +63 -0
  139. bai_python_hwc/answers/hwc506.py +61 -0
  140. bai_python_hwc/answers/hwc508.py +60 -0
  141. bai_python_hwc/answers/hwc509.py +85 -0
  142. bai_python_hwc/answers/hwc510.py +56 -0
  143. bai_python_hwc/answers/hwc511.py +52 -0
  144. bai_python_hwc/answers/hwc513.py +63 -0
  145. bai_python_hwc/answers/hwc514.py +74 -0
  146. bai_python_hwc/answers/hwc515.py +83 -0
  147. bai_python_hwc/answers/hwc516.py +67 -0
  148. bai_python_hwc/answers/hwc517.py +46 -0
  149. bai_python_hwc/answers/hwc520.py +54 -0
  150. bai_python_hwc/answers/hwc526.py +58 -0
  151. bai_python_hwc/attachments/hwc424.pdf +0 -0
  152. bai_python_hwc/attachments/hwc501.pdf +0 -0
  153. bai_python_hwc/questions/hwc101.txt +17 -0
  154. bai_python_hwc/questions/hwc103.txt +27 -0
  155. bai_python_hwc/questions/hwc104.txt +22 -0
  156. bai_python_hwc/questions/hwc105.txt +23 -0
  157. bai_python_hwc/questions/hwc106.txt +26 -0
  158. bai_python_hwc/questions/hwc107.txt +29 -0
  159. bai_python_hwc/questions/hwc108.txt +18 -0
  160. bai_python_hwc/questions/hwc109.txt +24 -0
  161. bai_python_hwc/questions/hwc110.txt +16 -0
  162. bai_python_hwc/questions/hwc111.txt +25 -0
  163. bai_python_hwc/questions/hwc112.txt +13 -0
  164. bai_python_hwc/questions/hwc113.txt +28 -0
  165. bai_python_hwc/questions/hwc114.txt +35 -0
  166. bai_python_hwc/questions/hwc115.txt +15 -0
  167. bai_python_hwc/questions/hwc116.txt +13 -0
  168. bai_python_hwc/questions/hwc117.txt +14 -0
  169. bai_python_hwc/questions/hwc118.txt +25 -0
  170. bai_python_hwc/questions/hwc119.txt +18 -0
  171. bai_python_hwc/questions/hwc120.txt +23 -0
  172. bai_python_hwc/questions/hwc121.txt +26 -0
  173. bai_python_hwc/questions/hwc122.txt +21 -0
  174. bai_python_hwc/questions/hwc123.txt +21 -0
  175. bai_python_hwc/questions/hwc124.txt +19 -0
  176. bai_python_hwc/questions/hwc125.txt +31 -0
  177. bai_python_hwc/questions/hwc126.txt +18 -0
  178. bai_python_hwc/questions/hwc127.txt +17 -0
  179. bai_python_hwc/questions/hwc128.txt +14 -0
  180. bai_python_hwc/questions/hwc130.txt +23 -0
  181. bai_python_hwc/questions/hwc131.txt +19 -0
  182. bai_python_hwc/questions/hwc132.txt +16 -0
  183. bai_python_hwc/questions/hwc133.txt +39 -0
  184. bai_python_hwc/questions/hwc134.txt +22 -0
  185. bai_python_hwc/questions/hwc135.txt +29 -0
  186. bai_python_hwc/questions/hwc136.txt +20 -0
  187. bai_python_hwc/questions/hwc201.txt +20 -0
  188. bai_python_hwc/questions/hwc202.txt +25 -0
  189. bai_python_hwc/questions/hwc203.txt +26 -0
  190. bai_python_hwc/questions/hwc204.txt +32 -0
  191. bai_python_hwc/questions/hwc205.txt +28 -0
  192. bai_python_hwc/questions/hwc206.txt +28 -0
  193. bai_python_hwc/questions/hwc207.txt +16 -0
  194. bai_python_hwc/questions/hwc208.txt +27 -0
  195. bai_python_hwc/questions/hwc209.txt +15 -0
  196. bai_python_hwc/questions/hwc210.txt +28 -0
  197. bai_python_hwc/questions/hwc211.txt +35 -0
  198. bai_python_hwc/questions/hwc212.txt +29 -0
  199. bai_python_hwc/questions/hwc213.txt +27 -0
  200. bai_python_hwc/questions/hwc214.txt +27 -0
  201. bai_python_hwc/questions/hwc215.txt +28 -0
  202. bai_python_hwc/questions/hwc216.txt +22 -0
  203. bai_python_hwc/questions/hwc217.txt +17 -0
  204. bai_python_hwc/questions/hwc218.txt +18 -0
  205. bai_python_hwc/questions/hwc219.txt +22 -0
  206. bai_python_hwc/questions/hwc220.txt +28 -0
  207. bai_python_hwc/questions/hwc221.txt +18 -0
  208. bai_python_hwc/questions/hwc222.txt +20 -0
  209. bai_python_hwc/questions/hwc223.txt +18 -0
  210. bai_python_hwc/questions/hwc224.txt +23 -0
  211. bai_python_hwc/questions/hwc225.txt +26 -0
  212. bai_python_hwc/questions/hwc226.txt +18 -0
  213. bai_python_hwc/questions/hwc227.txt +15 -0
  214. bai_python_hwc/questions/hwc228.txt +16 -0
  215. bai_python_hwc/questions/hwc229.txt +20 -0
  216. bai_python_hwc/questions/hwc230.txt +18 -0
  217. bai_python_hwc/questions/hwc231.txt +13 -0
  218. bai_python_hwc/questions/hwc232.txt +19 -0
  219. bai_python_hwc/questions/hwc233.txt +21 -0
  220. bai_python_hwc/questions/hwc234.txt +27 -0
  221. bai_python_hwc/questions/hwc235.txt +18 -0
  222. bai_python_hwc/questions/hwc236.txt +23 -0
  223. bai_python_hwc/questions/hwc237.txt +28 -0
  224. bai_python_hwc/questions/hwc238.txt +25 -0
  225. bai_python_hwc/questions/hwc239.txt +28 -0
  226. bai_python_hwc/questions/hwc240.txt +21 -0
  227. bai_python_hwc/questions/hwc241.txt +25 -0
  228. bai_python_hwc/questions/hwc242.txt +23 -0
  229. bai_python_hwc/questions/hwc243.txt +35 -0
  230. bai_python_hwc/questions/hwc244.txt +25 -0
  231. bai_python_hwc/questions/hwc245.txt +24 -0
  232. bai_python_hwc/questions/hwc246.txt +28 -0
  233. bai_python_hwc/questions/hwc247.txt +51 -0
  234. bai_python_hwc/questions/hwc301.txt +23 -0
  235. bai_python_hwc/questions/hwc302.txt +26 -0
  236. bai_python_hwc/questions/hwc303.txt +32 -0
  237. bai_python_hwc/questions/hwc304.txt +32 -0
  238. bai_python_hwc/questions/hwc305.txt +31 -0
  239. bai_python_hwc/questions/hwc306.txt +31 -0
  240. bai_python_hwc/questions/hwc307.txt +29 -0
  241. bai_python_hwc/questions/hwc308.txt +30 -0
  242. bai_python_hwc/questions/hwc309.txt +25 -0
  243. bai_python_hwc/questions/hwc310.txt +15 -0
  244. bai_python_hwc/questions/hwc311.txt +23 -0
  245. bai_python_hwc/questions/hwc312.txt +19 -0
  246. bai_python_hwc/questions/hwc313.txt +26 -0
  247. bai_python_hwc/questions/hwc314.txt +27 -0
  248. bai_python_hwc/questions/hwc315.txt +21 -0
  249. bai_python_hwc/questions/hwc316.txt +36 -0
  250. bai_python_hwc/questions/hwc317.txt +28 -0
  251. bai_python_hwc/questions/hwc318.txt +27 -0
  252. bai_python_hwc/questions/hwc319.txt +26 -0
  253. bai_python_hwc/questions/hwc320.txt +42 -0
  254. bai_python_hwc/questions/hwc321.txt +27 -0
  255. bai_python_hwc/questions/hwc322.txt +26 -0
  256. bai_python_hwc/questions/hwc323.txt +24 -0
  257. bai_python_hwc/questions/hwc324.txt +40 -0
  258. bai_python_hwc/questions/hwc325.txt +21 -0
  259. bai_python_hwc/questions/hwc326.txt +25 -0
  260. bai_python_hwc/questions/hwc327.txt +16 -0
  261. bai_python_hwc/questions/hwc328.txt +15 -0
  262. bai_python_hwc/questions/hwc329.txt +26 -0
  263. bai_python_hwc/questions/hwc330.txt +27 -0
  264. bai_python_hwc/questions/hwc332.txt +26 -0
  265. bai_python_hwc/questions/hwc401.txt +25 -0
  266. bai_python_hwc/questions/hwc402.txt +24 -0
  267. bai_python_hwc/questions/hwc403.txt +37 -0
  268. bai_python_hwc/questions/hwc404.txt +23 -0
  269. bai_python_hwc/questions/hwc405.txt +29 -0
  270. bai_python_hwc/questions/hwc406.txt +34 -0
  271. bai_python_hwc/questions/hwc407.txt +24 -0
  272. bai_python_hwc/questions/hwc408.txt +28 -0
  273. bai_python_hwc/questions/hwc409.txt +25 -0
  274. bai_python_hwc/questions/hwc410.txt +23 -0
  275. bai_python_hwc/questions/hwc411.txt +34 -0
  276. bai_python_hwc/questions/hwc412.txt +29 -0
  277. bai_python_hwc/questions/hwc413.txt +28 -0
  278. bai_python_hwc/questions/hwc414.txt +27 -0
  279. bai_python_hwc/questions/hwc415.txt +27 -0
  280. bai_python_hwc/questions/hwc416.txt +36 -0
  281. bai_python_hwc/questions/hwc418.txt +25 -0
  282. bai_python_hwc/questions/hwc419.txt +28 -0
  283. bai_python_hwc/questions/hwc421.txt +23 -0
  284. bai_python_hwc/questions/hwc424.txt +20 -0
  285. bai_python_hwc/questions/hwc501.txt +23 -0
  286. bai_python_hwc/questions/hwc502.txt +41 -0
  287. bai_python_hwc/questions/hwc503.txt +36 -0
  288. bai_python_hwc/questions/hwc504.txt +18 -0
  289. bai_python_hwc/questions/hwc505.txt +25 -0
  290. bai_python_hwc/questions/hwc506.txt +32 -0
  291. bai_python_hwc/questions/hwc508.txt +24 -0
  292. bai_python_hwc/questions/hwc509.txt +42 -0
  293. bai_python_hwc/questions/hwc510.txt +25 -0
  294. bai_python_hwc/questions/hwc511.txt +23 -0
  295. bai_python_hwc/questions/hwc513.txt +25 -0
  296. bai_python_hwc/questions/hwc514.txt +35 -0
  297. bai_python_hwc/questions/hwc515.txt +46 -0
  298. bai_python_hwc/questions/hwc516.txt +26 -0
  299. bai_python_hwc/questions/hwc517.txt +20 -0
  300. bai_python_hwc/questions/hwc520.txt +27 -0
  301. bai_python_hwc/questions/hwc526.txt +36 -0
  302. bai_python_hwc-1.0.0.dist-info/METADATA +41 -0
  303. bai_python_hwc-1.0.0.dist-info/RECORD +305 -0
  304. bai_python_hwc-1.0.0.dist-info/WHEEL +5 -0
  305. bai_python_hwc-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,27 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目: 最小操作次数使数组元素相等
13
+
14
+ 给你一个长度为 n 的整数数组,现在有一种操作, 该操作不会处理选定的数, 而使其他 n-1 个元素的数值增加 1 。求返回让数组所有元素相等的最小操作次数。
15
+
16
+ 示例 1:
17
+
18
+ 输入:nums = [1,2,3]
19
+ 输出:3
20
+ 解释:
21
+ 只需要3次操作(注意每次操作会增加两个元素的值):
22
+ [1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]
23
+
24
+ 示例 2:
25
+
26
+ 输入:nums = [1,1,1]
27
+ 输出:0
@@ -0,0 +1,26 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序("原地"即直接在原数组 nums 上修改,不新建等长的新数组),使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列;函数返回修改后的 nums。
14
+ 此题中,我们使用整数 0、1 和 2 分别表示红色、白色和蓝色。
15
+
16
+ 示例 1:
17
+ 输入:nums = [2,0,2,1,1,0]
18
+ 输出:[0,0,1,1,2,2]
19
+
20
+ 示例 2:
21
+ 输入:nums = [2,0,1]
22
+ 输出:[0,1,2]
23
+
24
+ 示例 3:
25
+ 输入:nums = [0]
26
+ 输出:[0]
@@ -0,0 +1,25 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:找到 K 个最接近的元素
13
+ 给定一个排序好的数组arr,两个整数k和x,从数组中找到最靠近x(两数之差最小)的k个数。返回的结果必须要是按升序排好的。
14
+ 整数a比整数b更接近x需要满足:
15
+ |a - x| < |b - x|或者
16
+ |a - x| == |b - x|且a < b
17
+
18
+ 示例:
19
+ 输入:arr = [1,2,3,4,5], k = 4, x = 3输出:[1,2,3,4]
20
+
21
+ 提示:
22
+ 1 <= k <= len(arr)
23
+ 1 <= len(arr) <= 10**4
24
+ arr按升序排列
25
+ -10**4 <= arr[i], x <= 10**4
@@ -0,0 +1,24 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:格雷编码
13
+ n 位格雷码序列是一个由 2^n 个整数组成的序列,其中:
14
+ 每个整数都在范围 [0, 2^n - 1] 内(含 0 和 2^n - 1)
15
+ 第一个整数是0
16
+ 一个整数在序列中出现不超过一次
17
+ 每对相邻整数的二进制表示恰好一位不同,且第一个和最后一个整数的二进制表示恰好一位不同
18
+ 给你一个整数n,返回任一有效的n 位格雷码序列。
19
+ (用大白话说:把 0 到 2^n-1 这些整数排成一圈,要求相邻两个数写成二进制后只有 1 位不同,从 0 开始即可。)
20
+
21
+ 示例:
22
+ 输入:n = 2输出:[0,1,3,2]
23
+
24
+ 提示:1<=n<=16
@@ -0,0 +1,37 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 给定一个无重复元素的数组candidates和一个目标数target,找出candidates中所有可以使数字和为target的组合。
14
+
15
+ 说明:
16
+ 1.所有数字(包括target)都是正整数。
17
+ 2.解集不能包含重复的组合。
18
+ 3.candidates中的数字可以无限制重复被选取,组合的顺序任意。
19
+
20
+ 示例1:
21
+
22
+ 输入:candidates = [2,3,6,7], target = 7,
23
+ 所求解集为:
24
+ [
25
+ [7],
26
+ [2,2,3]
27
+ ]
28
+
29
+ 示例2:
30
+
31
+ 输入:candidates = [2,3,5], target = 8,
32
+ 所求解集为:
33
+ [
34
+ [2,2,2,2],
35
+ [2,3,3],
36
+ [3,5]
37
+ ]
@@ -0,0 +1,23 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。
13
+ 有效括号组合需满足:左括号必须以正确的顺序闭合。
14
+
15
+ 示例 1:
16
+
17
+ 输入: n = 3
18
+ 输出: ["((()))","(()())","(())()","()(())","()()()"]
19
+
20
+ 示例 2:
21
+
22
+ 输入: n = 1
23
+ 输出: ["()"]
@@ -0,0 +1,29 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:解码字符串
13
+ 给定一个经过编码的字符串,返回它解码后的字符串。
14
+
15
+ 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次。注意 k 保证为正整数。
16
+
17
+ 你可以认为输入字符串总是有效的;输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的。
18
+
19
+ 此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数 k ,例如不会出现像 3a 或 2[4] 的输入。
20
+
21
+ 示例 1:
22
+
23
+ 输入:s = "3[a]2[bc]"
24
+ 输出:"aaabcbc"
25
+
26
+ 示例 2:
27
+
28
+ 输入:s = "3[a2[c]]"
29
+ 输出:"accaccacc"
@@ -0,0 +1,34 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。
14
+ 这个地方所有的房屋都 围成一圈 ,这意味着第一个房屋和最后一个房屋是紧挨着的。
15
+ 同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警 。
16
+
17
+ 给定一个代表每个房屋存放金额的非负整数数组,计算你 在不触动警报装置的情况下 (只去偷1个晚上),能够偷窃到的最高金额。
18
+ 若 nums 为空,返回 0。
19
+
20
+ 示例1:
21
+
22
+ 输入:nums = [2,3,2]
23
+ 输出:3
24
+ 解释:你不能先偷窃 1 号房屋(金额 = 2),然后偷窃 3 号房屋(金额 = 2), 因为他们是相邻的。
25
+ 示例 2:
26
+
27
+ 输入:nums = [1,2,3,1]
28
+ 输出:4
29
+ 解释:你可以先偷窃 1 号房屋(金额 = 1),然后偷窃 3 号房屋(金额 = 3)。
30
+ 偷窃到的最高金额 = 1 + 3 = 4 。
31
+ 示例 3:
32
+
33
+ 输入:nums = [0]
34
+ 输出:0
@@ -0,0 +1,24 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目
13
+ 给定一个字符串,请你找出其中不含有重复字符的 最长子串的长度。
14
+ (子串:字符串中连续的一段,例如 "abc" 是 "abcabcbb" 的子串。)
15
+
16
+ 示例:
17
+ 输入: s = "abcabcbb"
18
+ 输出: 3
19
+ 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
20
+ 示例 2:
21
+
22
+ 输入: s = "bbbbb"
23
+ 输出: 1
24
+ 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
@@ -0,0 +1,28 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 找出两个字符串之间的最长公共子字符串。
14
+ 例如:现有2个字符串,s1,s2;
15
+ s1 = "ABABC"
16
+ s2 = "BABCA"
17
+ s1和s2之间的最长公共子字符串即为"BABC"
18
+ 在result中只返回字符串: "BABC"。
19
+
20
+ 现有以下3组字符串,请找出每组字符串的最长公共子字符串。
21
+ a1 = "ABABCGRFGGJDJFKLSJDFKLJSLG"
22
+ a2 = "BABCACGJISEJGIOSDJGIOSDGJG"
23
+
24
+ b1 = "SDASQWERTYUIOPVJDKKVHNJKDN"
25
+ b2 = "QWERTYUIOPFDSFKSJFFNJSDFFF"
26
+
27
+ c1 = "RERFZXCVBNMJKLJKLJKLJKLJKL"
28
+ c2 = "WZXCVBNMFDUSHFUSDHFFHJDSFH"
@@ -0,0 +1,25 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:找出最具竞争力的子序列
13
+ 给你一个整数数组nums和一个正整数k,返回长度为k且最具竞争力的nums子序列。
14
+ 数组的子序列是从数组中删除一些元素(可能不删除元素)得到的序列。
15
+ 在子序列a和子序列b第一个不相同的位置上,如果a中的数字小于b中对应的数字,那么我们称子序列a比子序列b(相同长度下)更具竞争力。
16
+ 例如,[1,3,4]比[1,3,5]更具竞争力,在第一个不相同的位置,也就是最后一个位置上,4小于5。
17
+
18
+ 示例:
19
+ 输入:nums = [2,4,3,3,5,4,9,6], k = 4
20
+ 输出:[2,3,3,4]
21
+
22
+ 提示:
23
+ 1 <= nums.length <= 105
24
+ 0 <= nums[i] <= 109
25
+ 1 <= k <= nums.length
@@ -0,0 +1,23 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:单词拆分
13
+
14
+ 给定一个包含非空单词的字典 wordDict,编写函数 TEST_DO_NOT_CHANGE(s, wordDict),判断一个非空字符串 s 是否可以被空格拆分成一个或多个字典中出现的单词。
15
+
16
+ 假设字典为:wordDict = ["cats", "dog", "sand", "and", "cat"]
17
+
18
+ 对于以下输入:
19
+
20
+ s = "catsandog"
21
+
22
+
23
+ 应该返回 False,因为 "catsandog" 无法被拆分成字典中的单词。
@@ -0,0 +1,34 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+
14
+ 给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。
15
+ 你可以按 任何顺序 返回答案。
16
+
17
+
18
+
19
+
20
+
21
+ 示例 1:
22
+ 输入: n = 4, k = 2
23
+ 输出:
24
+ [[2,4],
25
+ [3,4],
26
+ [2,3],
27
+ [1,2],
28
+ [1,3],
29
+ [1,4],
30
+ ]
31
+
32
+ 示例 2:
33
+ 输入: n = 1, k = 1
34
+ 输出: [[1]]
@@ -0,0 +1,29 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+
14
+ 给定一个三角形 triangle ,找出自顶向下的最小路径和。
15
+
16
+ 每一步只能移动到下一行中相邻的结点上。
17
+ 相邻的结点在这里指的是下标与上一层结点下标相同或者等于上一层结点下标 + 1 的两个结点。
18
+ 也就是说,如果正位于当前行的下标 i ,那么下一步可以移动到下一行的下标 i 或 i + 1 。
19
+
20
+
21
+ 示例 1:
22
+
23
+ 输入: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
24
+ 输出: 11
25
+ 解释: 如下面简图所示:自顶向下的最小路径和为 11(即,2 + 3 + 5 + 1 = 11)。
26
+ [2]
27
+ [3,4]
28
+ [6,5,7]
29
+ [4,1,8,3]
@@ -0,0 +1,28 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目
13
+ 加油站问题:
14
+ 在一条环路上有 n 个加油站,其中第 i 个加油站有汽油 gas[i] 升。
15
+ 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。
16
+ 给定两个整数数组 gas 和 cost ,如果你可以按顺序绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1 。
17
+ 例如:gas = [1,2,3,4,5],cost = [3,4,5,1,2]
18
+ 从第0个位置开始,汽油不足以到达第1个位置。
19
+ 从第1个位置开始,汽油不足以到达第2个位置。
20
+ 从第2个位置开始,汽油不足以到达第3个位置。
21
+ 从第3个位置开始,可以绕圈一周。
22
+ 结果:从第3个位置开始。
23
+ 所以result返回值为:3
24
+
25
+ 有以下加油站配比组合,请按照示例返回出发时加油站的编号。
26
+ gas1 = [2,3,4,5,1], cost1 = [5,1,2,3,4]
27
+ gas2 = [3,3,4,0,2], cost2 = [2,3,4,0,1]
28
+ gas3 = [5,1,2,3,4], cost3 = [4,4,1,5,1]
@@ -0,0 +1,27 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 给定一个字符串S,通过将字符串S中的每个字母转变大小写,我们可以获得一个新的字符串。返回所有可能得到的字符串集合。
14
+
15
+ 示例 1:
16
+ 输入: S = "a1b2"
17
+ 输出: ["a1b2", "a1B2", "A1b2", "A1B2"]
18
+
19
+ 示例 2:
20
+ 输入: S = "3z4"
21
+ 输出: ["3z4", "3Z4"]
22
+
23
+ 示例 3:
24
+ 输入: S = "12345"
25
+ 输出: ["12345"]
26
+
27
+ 返回集合中的字符串顺序任意;判定时只比较结果集合,不要求固定顺序。
@@ -0,0 +1,27 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 给定一个包含非负整数的 m x n 网格 grid ,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。
14
+ 说明:每次只能向下或者向右移动一步。
15
+
16
+ 示例:grid = [
17
+ [1,3,1,5],
18
+ [1,5,1,3],
19
+ [4,2,1,5],
20
+ [2,5,3,1]
21
+ ],求得的最短路径数字总和为11。(1-3-1-1-1-3-1)
22
+ 因此,result输出值为 11
23
+
24
+ 有以下几个网格数据,请分别求出最短路径数字总和:
25
+ grid1 = [[2,3,1,4],[4,5,1,5],[1,7,4,9],[4,7,2,1]]
26
+ grid2 = [[1,4,3,2],[1,5,1,5],[2,1,3,1],[1,7,3,8]]
27
+ grid3 = [[3,1,1,2],[6,5,2,1],[5,7,1,2],[6,2,2,3]]
@@ -0,0 +1,36 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:使字符串总不同字符的数目相等
13
+ 给你两个下标从 0 开始的字符串 word1 和 word2 。
14
+
15
+ 一次 移动 由以下两个步骤组成:
16
+ 1.选中两个下标 i 和 j ,分别满足 0 <= i < word1.length 和 0 <= j < word2.length ,
17
+ 2.交换 word1[i] 和 word2[j] 。
18
+ 3.如果可以通过 恰好一次 移动,使 word1 和 word2 中不同字符的数目相等,则返回 True ;否则,返回 False 。
19
+
20
+ 示例 1:
21
+
22
+ 输入:word1 = "ac", word2 = "b"
23
+ 输出:False
24
+ 解释:交换任何一组下标都会导致第一个字符串中有 2 个不同的字符,而在第二个字符串中只有 1 个不同字符。
25
+
26
+ 示例 2:
27
+
28
+ 输入:word1 = "abcc", word2 = "aab"
29
+ 输出:True
30
+ 解释:交换第一个字符串的下标 2 和第二个字符串的下标 0 。之后得到 word1 = "abac" 和 word2 = "cab" ,各有 3 个不同字符。
31
+
32
+ 示例 3:
33
+
34
+ 输入:word1 = "abcde", word2 = "fghij"
35
+ 输出:True
36
+ 解释:无论交换哪一组下标,两个字符串中都会有 5 个不同字符。
@@ -0,0 +1,25 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目
13
+ 给定一个没有重复数字的序列,返回其所有可能的全排列。
14
+
15
+ 示例:
16
+ 输入: [1,2,3]
17
+ 输出:
18
+ [
19
+ [1,2,3],
20
+ [1,3,2],
21
+ [2,1,3],
22
+ [2,3,1],
23
+ [3,1,2],
24
+ [3,2,1]
25
+ ]
@@ -0,0 +1,28 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:给定两个以字符串形式表示的非负整数num1和num2,返回num1和num2的乘积,它们的乘积也表示为字符串形式。
13
+
14
+ 示例 1:
15
+
16
+ 输入: num1 = "2", num2 = "3"
17
+ 输出: "6"
18
+
19
+ 示例2:
20
+
21
+ 输入: num1 = "123", num2 = "456"
22
+ 输出: "56088"
23
+
24
+ 注意:
25
+ 1.num1和num2的长度小于110。
26
+ 2.num1 和num2 只包含数字0-9。
27
+ 3.num1 和num2均不以零开头,除非是数字 0 本身。
28
+ 4.不能使用任何标准库的大数类型(比如 BigInteger)或直接将输入转换为整数来处理。
@@ -0,0 +1,23 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:连续差相同的数字
13
+ 返回所有长度为n且满足其每两个连续位上的数字之间的差的绝对值为k的非负整数。
14
+ 请注意除了数字0本身之外,答案中的每个数字都不能有前导零。例如01有一个前导零,所以是无效的,但0是有效的。
15
+ 你可以按任何顺序返回答案。
16
+
17
+ 示例:
18
+ 输入:n=3,k=7
19
+ 输出:[181,292,707,818,929]
20
+
21
+ 提示:
22
+ 2 <= n <= 9
23
+ 0 <= k <= 9
@@ -0,0 +1,20 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。
14
+ 数字到字母的映射如下(与电话按键相同):2→abc,3→def,4→ghi,5→jkl,
15
+ 6→mno,7→pqrs,8→tuv,9→wxyz。注意 1 不对应任何字母。
16
+
17
+ 示例:
18
+
19
+ 输入:"23"
20
+ 输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
@@ -0,0 +1,23 @@
1
+ 请只在 "
2
+ ##########start下面可以改动
3
+
4
+ ##########end上面可以改动 "
5
+
6
+ 中间部分作答,作答行数自由调整
7
+
8
+ 请不要使用 input() 函数
9
+
10
+ 此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
11
+
12
+ 题目:
13
+ 参考同目录中的 hwc501.pdf(图 1 为题目所需图形)。
14
+
15
+
16
+ 使用 Python 语言并采用蒙特卡洛方法求 hwc501.pdf 图 1 中阴影部分的面积。
17
+ 请在报告中说明采样矩形的边界、阴影区域的判定条件,并使用 random.seed(2026) 固定随机种子。
18
+ import random
19
+ random.random() #返回[0.0,1)之间的浮点数
20
+ random.uniform(a, b)#返回[a,b]之间的浮点数
21
+ random.randint(a, b)#返回[a,b]之间的整数
22
+
23
+ 建议:至少产生 100000 个样本点;以样本比例乘采样矩形面积作为估计值,并给出误差阈值(建议绝对误差不超过 0.1)及验收标准。