fork download
  1. /**
  2.  * Definition for singly-linked list.
  3.  * struct ListNode {
  4.  * int val;
  5.  * ListNode *next;
  6.  * ListNode(int x) : val(x), next(NULL) {}
  7.  * };
  8.  */
  9. ListNode* Solution::deleteDuplicates(ListNode* A) {
  10. ListNode *head = A, *tmp;
  11.  
  12. while(head != NULL){
  13. tmp = head->next;
  14. //bool b = 0;
  15.  
  16. while(tmp != 0 && tmp->val == head->val){
  17. //cout << tmp->val << " " << head->val << endl;
  18.  
  19. //b = 1;
  20. ListNode *tmp_two = tmp;
  21. tmp = tmp_two->next;
  22. delete tmp_two;
  23. }
  24.  
  25. cout << head->val << endl;
  26. head = tmp;
  27. //cout << head->val << endl;
  28. }
  29.  
  30. return A;
  31. }
  32.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:9:1: error: ‘ListNode’ does not name a type
 ListNode* Solution::deleteDuplicates(ListNode* A) {
 ^~~~~~~~
stdout
Standard output is empty