* Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
| 50 | * }; |
| 51 | */ |
| 52 | class Solution { |
| 53 | public: |
| 54 | int numComponents(ListNode* head, vector<int>& G) { |
| 55 | unordered_set<int> s(G.begin(),G.end()); |
| 56 | ListNode* temp=head; |
| 57 | int c=0; |
| 58 | while(temp){ |
| 59 | if(s.find(temp->val)!=s.end()){ |
| 60 | c++; |
| 61 | while(temp and s.find(temp->val)!=s.end()) |
| 62 | temp=temp->next; |
| 63 | continue; |
| 64 | } |
| 65 | temp=temp->next; |
| 66 | } |
| 67 | return c; |
| 68 | |
| 69 | |
| 70 | } |
| 71 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected