category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

160. Intersection of Two Linked Lists , Easy

code ```cpp int Size(ListNode* head) { int count = 0; while (head != nullptr) { head = head -> next; count ++; } return count; } ListNode *findIntersection(ListNode* one, ListNode* two) { if (one == two) return one; while (one != nullptr and two != nullptr) { one = one -> next; two = two -> next; if (one == two) return one; } return nullptr; } ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { auto one = headA; auto two = headB; int count1 = Size(one); int count2 = Size(two); one = headA; two = headB; int diff = count1 - count2; if (diff > 0) { while (diff--) one = one -> next; } else { diff *= -1; while (diff--) two = two -> next; } return findIntersection(one, two); } ```