본문 바로가기
Programming/Data Structure

[Hackerrank] InsertNodeAtHead

by 읽고 쓰는 개발자 2020. 12. 2.

www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list/problem

Insert a node at the head of a linked list | HackerRank

Create and insert a new node at the head of a linked list

www.hackerrank.com

package exam.complete;

//https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list/problem

import exam.SinglyLinkedListNode;

public class InsertNodeAtHead {

    static SinglyLinkedListNode insertNodeAtHead(SinglyLinkedListNode llist, int data) {
        SinglyLinkedListNode node = new SinglyLinkedListNode(data);
        node.next = llist;
        return node;
    }
}

'Programming > Data Structure' 카테고리의 다른 글

[Hackerrank] InsertNodeAtTail  (0) 2020.12.02
[Hackerrank] InsertNodeAtPosition  (0) 2020.12.02
[Hackerrank] GetNodeValue  (0) 2020.12.02
[Hackerrank] FindMergePointofTwoLists  (0) 2020.12.02
[Hackerrank] DeleteNode  (0) 2020.12.02