DAY 15 LINKED LIST HACKKERANK

  public static  Node insert(Node head,int data) {

        Node newNode=new Node(data); 
        Node temp=head;
        if(head==null){
            head=newNode;
            return head;
        }
        else{
            while(temp.next!=null){
                temp=temp.next;
            }
            temp.next=newNode;
            return head;
        }
        //Complete this method
    }

Comments

Popular posts from this blog

Java Date And Time HackerRank

Recursive Sequence Geeks For Geeks Problem Of The Day 12-02-2024

Minimum Indices HackerEarth