Code is throwing mismatch input error on below code

Having run the code on leetcode, I know this code is correct. Could you explain why I’m getting an error?

Node current1 = l1;
Node current2 = l2;
HashSet set = new HashSet();

    while(current1 != null){
        set.add(current1);
        current1 = current1.next;
    }

    while(current2 != null){
        if(set.contains(current2)) return current2;
        current2 = current2.next;
    }

    return null;

hey @aditikanaujia72_4531383e6a802ab3 Can you elaborate what kind of error you are getting and please send me your full code.

Hey @aditikanaujia72_4531383e6a802ab3 There is a problem with the pre-code provided So I Have checked your solution and there is no problem with your solution so dont worry and I will take care of the pre-code from my side and will update you about that. After which you can Submit the solution.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.