Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

622
Vistas
Implement the addInPos method inside the prototype of LinkedList which should add an element in the indicated position

Implement the addInPos method inside the prototype of LinkedList which should add an element in the indicated position. Both data will be provided as a parameter (pos, values). Where "pos" will be the position in which the value "values" should be added.

In the event that the position in which the insertion is to be made is not valid (exceeds the size of the current list), it must return false. If the node was added correctly, return true. Clarification: the zero position corresponds to the head of the LinkedLis.

  • Example 1:

Assuming the current list is: Head --> [1] --> [2] --> [4]

list.addInPos(2, 3);

Now the list would be: Head --> [1] --> [2] --> [3] --> [4]

  • Example 2:

Assuming the list is empty: Head --> null.

list.addInPos(2, 3); --> Should return false since it is not possible to add at position 2 without first having position 0 and 1 loaded

LinkedList.prototype.addInPos = function (pos, values) {
    /* Your code here */
}
if(!this.head)
  {
    this.head = new Node(values);
    return;
  }

  // not empty find the place with getAt and insert
  let previo = this.getAt(pos - 1);
  let tmpNodo = new Node(values);
  tmpNodo.next = previo.next;
  previo.next = tmpNodo;
  return this.head;
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda