Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

359
Views
En la segunda iteración del bucle, ¿comienza con el bucle for p o deja a la izquierda (P) para ayudarme a comprender el flujo del código?
const elevationArray = [0, 1, 0, 2, 1, 0, 3, 1, 0, 1, 2] const getTrappedRainwater = function(heights) { let totalWater = 0; for(let p = 0; p < heights.length; p++) { let leftP = p, rightP = p, maxLeft = 0, maxRight = 0; while(leftP >= 0) { maxLeft = Math.max(maxLeft, heights[leftP]); leftP--; } while(rightP < heights.length) { maxRight = Math.max(maxRight, heights[rightP]); rightP++; } const currentWater = Math.min(maxLeft, maxRight) - heights[p]; if(currentWater >= 0) { totalWater += currentWater; } } return totalWater; } console.log(getTrappedRainwater(elevationArray));
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!