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

289
Views
Error de lanzamiento de solución de problemas de Leetcode, por favor ayude

Error de lanzamiento de la solución de problemas de Leetcode, por favor ayude MI CÓDIGO FUNCIONA BIEN NO LLEGO DE DÓNDE PROVIENE EL PROBLEMA POR FAVOR AYÚDAME SEÑOR

Se le dan dos listas enlazadas no vacías que representan dos enteros no negativos. Los dígitos se almacenan en orden inverso y cada uno de sus nodos contiene un solo dígito. Sume los dos números y devuelva la suma como una lista enlazada.

Puede suponer que los dos números no contienen ningún cero inicial, excepto el propio número 0. ejemplo

 Example one Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 342 + 465 = 807. Example 2: Input: l1 = [0], l2 = [0] Output: [0] MY CODE var addTwoNumbers = function(l1, l2) { var alpha1 = "" var alpha2 = "" var arr = [] // Looping through first list l1 for(var i = 0; i< l1.length; i++){ alpha1 = l1[i]+alpha1 // converting l1 to string and setting it to ALPHA 1 } // Looping through second list L2 for(var i = 0; i< l2.length; i++){ alpha2 = l2[i]+alpha2 // converting l2 to string and setting it to ALPHA 2 } // Coverting alpha1 and apha2 to intergets and making their sum to a new variable string "New" var New = parseInt(alpha1) + parseInt(alpha2) New = New + "" for(var i=0;i<New.length; i++){ // Pushing the New variable is reverse order to arr and also converting it back to interger arr.push(parseInt(New[New.length-i-1])) } // Returning the array return arr }; addTwoNumbers([9,9,9,9,9,9,9],[9,9,9,9]) MY CODE WORKS JUST FINE ON CONSOLE THE ERROR Line 51 in solution.js throw new TypeError(__serialize__(ret) + " is not valid value for the expected return type ListNode"); ^ TypeError: [null,null,null] is not valid value for the expected return type ListNode Line 51: Char 20 in solution.js (Object.<anonymous>) Line 16: Char 8 in runner.js (Object.runner) Line 35: Char 26 in solution.js (Object.<anonymous>) Line 1251: Char 30 in loader.js (Module._compile) Line 1272: Char 10 in loader.js (Object.Module._extensions..js) Line 1100: Char 32 in loader.js (Module.load) Line 962: Char 14 in loader.js (Function.Module._load) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) Line 17: Char 47 in run_main_module.js
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La descripción del problema especifica que cada número puede tener hasta 100 dígitos. El entero más grande que se puede representar con precisión en Javascript tiene 16 dígitos. Entonces, su programa no funcionará para muchas entradas posibles, como verá si lo prueba con arreglos más grandes.

about 4 years ago · Juan Pablo Isaza Report
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!