
result = [] for i in n: for jj in range(len(m)): if jj < 3: result.append((n,m)) else: jj = len(m) n and m are two Python array.
时间复杂度是多少呢?
讨论一下?
1 kuangwinnie 2021-06-04 06:22:29 +08:00 ??这难道不是取决于你 m 是不是定值吗 |
2 jhdxr 2021-06-04 07:37:39 +08:00 『 O(n) 因为 inner loop is fixed always 3 』是错的 例如 m 的长度是 10,尽管你 result 只`append`了 3 次,但你的`jj=len(m)`会执行 7 次 |
3 polaa 2021-06-04 09:09:22 +08:00 O(n*len(m)) |
4 FurN1 2021-06-04 09:39:29 +08:00 0 因为两个空格缩进的 Python 跑不了 |
5 rrfeng 2021-06-04 10:05:39 +08:00 @IgniteWhite 哈哈哈哈哈哈,启动解释器和读取文件的时间不算了吗 |
7 way2explore2 OP |