Single Linkded List in C++
1. Print
2. Append
3. Remove
4. Count
5. Reverse
class SLL{
    public:
        Node* head;
        SLL(){head = NULL;};
    public:
    void append(int data){
        if(head){
            Node* curr = head;
            while(curr->right){
                curr = curr->right;
            }
            curr->right = new Node(data); 
        }else{
            head = new Node(data);
        }
    }
    void append(Node* node){
        if(head){
            Node* curr = head;
            while(curr->right){
                curr = curr->right;
            }
            curr->right = node; 
        }else{
            head = node;
        }
    }
    void print(){
        Node* curr = head;
        while(curr){
            std::cout<<"["<<curr->data<<"]"<<std::endl;
            curr = curr->right;
        }
    }
    int count(){
        Node* curr = head;
        int count = 0;
        while(curr){
            count++;
            curr = curr->right;
        }
        return count;
    }
    void remove(Node* node){
        Node* curr = head;
        if(curr != NULL && node != NULL){
            Node* prev = NULL;
            Node* right = curr->right;
            while(curr){
                if(curr == node){
                    if(prev){
                        prev->right = right;
                        curr->right = NULL;
                    }else{
                        head = right;
                        curr->right = NULL;
                    }
                    delete curr;
                    curr = NULL;
                }else{
                    prev = curr;
                    curr = curr->right;
                    if(curr)
                        right = curr->right;
                }
            }
        }
    }
    
};