We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 15: Linked List
Day 15: Linked List
+ 0 comments Typescript is not working for set 3. I don't understand why it was not working.
process.stdin.on('end', function(): void { inputLines = inputString.split('\n'); inputString = ''; main(inputLines); }); function main(inputLines: string[]) { let elements = inputLines.join("").split(''); let n = parseInt(elements.shift(), 10); // Print the elements array console.log(...elements); }
+ 0 comments Using C
Node* insert(Node *head,int data) { //Complete this function Node * tmp = head; Node *n = (Node*)malloc(sizeof(Node)); n->data = data; n->next = NULL; if(NULL == head){ head= n; }else{ if(tmp->next == NULL){ head->next=n; }else{ while(tmp->next != NULL){ tmp= tmp->next; if(tmp->next == NULL){ tmp->next = n; break; } } } } return head; }
+ 0 comments c#
if (head == null) { head = new Node(data); } else { Node currentNode = head; while (currentNode.next != null) { currentNode = currentNode.next; } currentNode.next = new Node(data); } return head;
+ 0 comments # JAVA 7.. class Solution {
public static Node insert(Node head,int data) { if(head == null) { head = new Node(data); } else{ Node a = head; while(a.next != null) { a=a.next; } a.next = new Node(data); } return head; }
+ 0 comments C++
Node* insert(Node *head,int data) { Node *myNode = new Node(data); if(head == NULL) { return myNode; } Node *tmp = head; while(tmp->next != NULL) { tmp = tmp->next; } tmp->next = myNode; return head; //Complete this method }
Load more conversations
Sort 692 Discussions, By:
Please Login in order to post a comment