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

173
Views
Dos punteros, problema de rotación de matriz en javascript

Estoy fallando porque la salida es la misma que la entrada, aunque no debería estar de acuerdo con mi última línea (nums = matriz).

 /** * @param {number[]} nums * @param {number} k * @return {void} Do not return anything, modify nums in-place instead. */ var rotate = function(nums, k) { let a=0; const array=[]; for(let i=0; i+k<=nums.length-1; i++){ array[i+k]=nums[i]; } for(let k=Math.ceil(nums.length/2); k<nums.length; k++){ array[a]=nums[k]; a++; } nums=array; };

Ejemplo de caso de prueba:

 Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6,7,1,2,3,4]

Esta es una pregunta de leetcode llamada Rotate Array (189). ¿Qué me falta? Soy principiante en la codificación.

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!