鱼C论坛

 找回密码
 立即注册
查看: 916|回复: 0

力扣题目报内存溢出错误

[复制链接]
发表于 2022-6-10 19:26:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
在写力扣题目时,报
<--- Last few GCs --->
[42:0x6602180]      359 ms: Mark-sweep (reduce) 133.2 (138.1) -> 82.7 (84.7) MB, 13.9 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 14 ms) (average mu = 0.770, current mu = 0.775) last resort G[42:0x6602180]      372 ms: Mark-sweep (reduce) 82.7 (84.7) -> 82.7 (84.4) MB, 12.7 / 0.0 ms  (average mu = 0.624, current mu = 0.001) last resort GC in old space requested
<--- JS stacktrace --->
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: 0xb00e10 node::Abort() [nodejs run]
2: 0xa1823b node::FatalError(char const*, char const*) [nodejs run]
3: 0xcee09e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [nodejs run]
4: 0xcee417 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [nodejs run]
5: 0xea65d5  [nodejs run]
6: 0xeb8a58 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [nodejs run]
7: 0xe79b12 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [nodejs run]
8: 0xe7443c v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawArray(int, v8::internal::AllocationType) [nodejs run]
9: 0xe74515 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller(v8::internal::Handle<v8::internal::Map>, int, v8::internal::Handle<v8::internal::Oddball>, v8::internal::AllocationType) [nodejs run]
10: 0x10221b2  [nodejs run]
11: 0x1022af6  [nodejs run]
12: 0x11e3783 v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [nodejs run]
13: 0x15e7cf9  [nodejs run]
错误
题为力扣 121. 买卖股票的最佳时机
我的代码为:
  1. /**
  2. * @param {number[]} prices
  3. * @return {number}
  4. */
  5. var maxProfit = function(prices) {
  6.     let result=[]
  7.     if(prices.length<=1){
  8.         return 0
  9.     }
  10.    
  11.     for(let i=0;i<prices.length;i++){
  12.         for(let j=i+1;j<prices.length;j++){
  13.             if((prices[j]-prices[i])<0){
  14.                 result.push(0)
  15.             }
  16.             else{
  17.                 result.push(prices[j]-prices[i])
  18.             }
  19.         }
  20.     }
  21.     result.sort(function(a, b){return a-b})
  22.     return result[result.length-1]
  23. };
复制代码

不知道哪里错了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-26 21:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表