当前位置:网站首页>Memory Limit Exceeded
Memory Limit Exceeded
2022-06-30 19:06:00 【Just change your name】
A dead cycle leads to
It is not necessarily because you have created too many variables explicitly , For example, create too many lists , Dictionaries, etc .
It could be a dead cycle , Writing the loop by yourself does not make the key variables of the loop exit change during the loop process ,
The cycle is running , Memory keeps increasing , Cause the memory limit to be exceeded .
For example, let's find the factor of a certain number , Initialization factor fac by 1,
Each cycle ,fac It should increase by itself 1, And mirror pairs ,
An error will be reported that the memory is out of limit ,
It didn't report TLE, So it's hard to find .
def get_fac(self, target):
if target == 1:
return []
fac = 1
facs = []
while fac*fac <= target:
if target % fac == 0: # in O(N)
facs.append(fac) # list index O(N)
if fac != 1 and fac*fac != target:
facs.append(target//fac)
# fac += 1 # I forgot to write here
return facs
Lists lead to
Maybe the list takes up a lot of memory , Just change to a dictionary , This applies only to situations that can be replaced by dictionaries .
边栏推荐
- 华兴证券:混合云原生架构下的 Kitex 实践
- 英飞凌--GTM架构-Generic Timer Module
- Large file transfer software based on UDP protocol
- 系统集成项目管理工程师认证高频考点:编制项目范围管理计划
- 基于UDP协议设计的大文件传输软件
- Hospital online consultation applet source code Internet hospital source code smart hospital source code
- 「经验」爬虫在工作中的实战应用『理论篇』
- Four tips tell you how to use SMS to promote business sales?
- System integration project management engineer certification high frequency examination site: prepare project scope management plan
- 一文详解|Go 分布式链路追踪实现原理
猜你喜欢
随机推荐
Multipass Chinese document - setting graphical interface
Compilation problems and solutions of teamtalk winclient
教你30分钟快速搭建直播间
Summary of methods for offline installation of chrome extensions in China
Merged binary tree of leetcode
PC wechat multi open
Infineon - GTM architecture -generic timer module
3.10 haas506 2.0 development tutorial example TFT
删除排序链表中的重复元素 II[链表节点统一操作--dummyHead]
Swin-Transformer(2021-08)
全栈代码测试覆盖率及用例发现系统的建设和实践
深度学习编译器的理解
20220607跌破建议零售价,GPU市场正全面走向供过于求...
C# Winform程序界面优化实例
com.alibaba.fastjson.JSONObject # toJSONString 消除循环引用
Redis入门到精通01
ONEFLOW source code parsing: automatic inference of operator signature
C WinForm program interface optimization example
Courage to be hated: Adler's philosophy class: the father of self inspiration
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线









