Need Help! Store A's Address in a hash map, and if B has some address from the map use ".find()".


  • 0

    i get problem. I plan to store all the address of A in a map or hash table. I thought I could use the find() function easily compare to each address in B. However, I met the compiling error could not get through. Hope someone may give me some suggestion. Really appreciate.

    ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) 
    {
    if(headA==NULL || headB==NULL)
     return NULL;
     ListNode *ptr= headA;
    
    
    map <&ListNode> AddressMap;
    while(ptr!=NULL)
    {
        AddressMap(&ptr,0);
        ptr=ptr->next;
    }
    ptr=headB;
    while(ptr=!NULL)
    {
      if(AddressMap.find(&ptr) != AddressMap.end())
       return ptr;
       else
        ptr=ptr->next;
    }
      return NULL; 
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.