# Find Merge Point of Two Lists

Given pointers to the head nodes of  2 linked lists that merge together at some point, find the Node where the two lists merge. It is guaranteed that the two head Nodes will be different, and neither will be NULL.

In the diagram below, the two lists converge at Node `x`:

```[List #1] a--->b--->c
\
x--->y--->z--->NULL
/
[List #2] p--->q

```

Sample Input

The diagrams below are graphical representations of the lists that input Nodes headA and headB and  are connected to. Recall that this is a method-only challenge; the method only has initial visibility to those 2  Nodes and must explore the rest of the Nodes using some algorithm of your own design.

Test Case 0

``` 1
\
2--->3--->NULL
/
1

```

Test Case 1

```1--->2
\
3--->Null
/
1
```

Sample Output

```2
3
```

Explanation

Test Case 0: As demonstrated in the diagram above, the merge Node’s data field contains the integer .
Test Case 1: As demonstrated in the diagram above, the merge Node’s data field contains the integer .

## Solution

```int FindMergeNode(Node headA, Node headB) {

//Do till the two nodes are the same
while(currentA != currentB){
//If you reached the end of one list start at the beginning of the other one
//currentA
if(currentA.next == null){
{"ft_lang_label":"__label__en","ft_lang_prob":0.76444805,"math_prob":0.90276927,"size":1397,"snap":"2020-45-2020-50","text_gpt3_token_len":367,"char_repetition_ratio":0.14501077,"word_repetition_ratio":0.09282701,"special_character_ratio":0.27272728,"punctuation_ratio":0.10780669,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9817374,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-28T03:27:42Z\",\"WARC-Record-ID\":\"<urn:uuid:a424d299-f2fd-4a79-b70a-52428a2288e5>\",\"Content-Length\":\"140194\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a6136d6f-737f-46b9-9d6e-0f52cdb336d0>\",\"WARC-Concurrent-To\":\"<urn:uuid:f93572e6-651c-461d-a046-1940477d8935>\",\"WARC-IP-Address\":\"192.0.78.24\",\"WARC-Target-URI\":\"https://developersinspired.com/2020/07/12/find-merge-point-of-two-lists/\",\"WARC-Payload-Digest\":\"sha1:BGAXVDZKBD2GLYZ7QXHVCA5BOJLNONL5\",\"WARC-Block-Digest\":\"sha1:H5C2JBR3VWYSJXIO2L5ZW2YTHYRJ2G7M\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107896048.53_warc_CC-MAIN-20201028014458-20201028044458-00555.warc.gz\"}"}