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

625
Views
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
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!