Код: Выделить всё
class Solution {
// Function to insert a node at the end of the linked list.
Node insertAtEnd(Node head, int x) {
// code here
if(head == null) {
Node node = new Node(x);
return node;
}
else{
Node mover = head;
while(mover.next != null ){
mover = mover.next;
}
Node newNode = new Node(x);
mover.next = newNode;
return head;
}
}
}
< /code>
Почему этот код дает TLE? и если я использую возвращать новый узел (x); Подробнее здесь: https://stackoverflow.com/questions/794 ... throws-tle