Java: Solution is accepted for Test Run but getting Time Exceed Message on Submission

New to Leet Code and trying to get my hands on for Linked List in Java. Below is my submission which is an accepted one and running good on the test input, but getting excess time message on submission. I am unable to catch the issue in program and seeking some good advice.

Thanks.

class MyLinkedList {
    Node head;
    int numberOfNodes=0;
    
    class Node{
        Node next;
        int val;
        Node(int x){
            val = x;  
        }              
    }
    
    /** Initialize your data structure here. */
    public MyLinkedList() {
          
    }
    
    /** Get the value of the index-th node in the linked list. If the index is invalid, return -1. */
    public int get(int index) {
        if(index<0 || index>=numberOfNodes)
            return -1;
        Node curr = head;
        for(int i=0;i<index;i++){
            curr = curr.next;
        }
        return curr.val;
    }
    
    /** Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. */
    public void addAtHead(int val) {
        numberOfNodes++;
        Node node = new Node(val);
        if(head == null){
            head = node;
        }else{
            node.next = head;    
            head = node;
        }
    }
    
    /** Append a node of value val to the last element of the linked list. */
    public void addAtTail(int val) {
        Node node = new Node(val);
        Node curr = head;
        while(curr.next!=null)
            curr = curr.next;
        curr.next = node;
        numberOfNodes++;
    }
    
    /** Add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. */
    public void addAtIndex(int index, int val) {
        if(index>numberOfNodes)
            return;
        if(index<=0)
            addAtHead(val);
        else if(index==numberOfNodes)
            addAtTail(val);
        else{
            Node curr = head;
            for(int i=1;i<index;i++)
                curr.next = curr;
            Node node = new Node(val);
            node.next = curr.next;
            curr.next = node;
        }
        numberOfNodes++;
    }
    
    /** Delete the index-th node in the linked list, if the index is valid. */
    public void deleteAtIndex(int index) {
        if(index<0 || index>=numberOfNodes)
            return;
        if(index==0){
            if(head==null)
                return;
            else{
                Node node = head.next;
                head = node;
            }
        }else{
            Node curr = head;
            int i=1;
            for(;i<index;i++)
                curr = curr.next;
            if(i==numberOfNodes-1){
                curr.next = null;
            }else{
                curr.next = curr.next.next;
            }
        }
        numberOfNodes--;
    }
}

/**
 * Your MyLinkedList object will be instantiated and called as such:
 * MyLinkedList obj = new MyLinkedList();
 * int param_1 = obj.get(index);
 * obj.addAtHead(val);
 * obj.addAtTail(val);
 * obj.addAtIndex(index,val);
 * obj.deleteAtIndex(index);
 */
Comments (2)