int main() { Solution s; { ListNode *node1 = new ListNode(1); ListNode *node2 = new ListNode(1); ListNode *node3 = new ListNode(2); node1->next = node2; node2->next = node3; print(s.deleteDuplicates(node1)); } { ListNode *node1 = new ListNode(1); ListNode *node2 = new ListNode(1); ListNode *node3 = new ListNode(2); ListNode *node4 = new ListNode(3); ListNode *node5 = new ListNode(3); node1->next = node2; node2->next = node3; node3->next = node4; node4->next = node5; print(s.deleteDuplicates(node1)); } return 0; }
int main() { Solution sln; ListNode* n1 = createListNode(vector<int>({1, 2, 3, 3, 4, 4, 5})); n1 = sln.deleteDuplicates(n1); printListNode(n1); n1 = createListNode(vector<int>({1, 1, 1, 2, 3})); n1 = sln.deleteDuplicates(n1); printListNode(n1); n1 = createListNode(vector<int>({1, 1, 1})); n1 = sln.deleteDuplicates(n1); printListNode(n1); return 0; }
int main() { ListNode * node1 = new ListNode(1); ListNode * node2 = new ListNode(1); /* ListNode * node3 = new ListNode(3); ListNode * node4 = new ListNode(3); ListNode * node5 = new ListNode(3); ListNode * node6 = new ListNode(5); ListNode * node7 = new ListNode(5); */ node1->next = node2; /* node2->next = node3; node3->next = node4; node4->next = node5; node5->next = node6; node6->next = node7; */ Solution s ; ListNode * head = s.deleteDuplicates(node1); while(head != NULL) { cout<<head->val<<endl; head = head->next; } return 0; }
int main() { ListNode *head = NULL, *curr; /* 生成链表 */ for (int i = 0; i < 2; ++i) { ListNode* node = new ListNode(1); if (head == NULL) { head = node; curr = node; } else { curr->next = node; curr = curr->next; } } Solution so; curr = so.deleteDuplicates(head); /* 打印并释放链表 */ ListNode* tmp; while (curr != NULL) { tmp = curr; cout << curr->val << " "; curr = curr->next; delete tmp; } cout << endl; return 0; }
int main ( int argc, char *argv[] ) { /*{ FILE* file = fopen(argv[1], "r"); int a, b; while(fscanf(file, "%d,%d", &a, &b) != EOF){ }*/ /* getI(T); int T; FE(cases,1,T){ printf("Cases #%d: ", cases); } }*/ /* Solution s = Solution(); */ Solution s = Solution(); ListNode* head = new ListNode(1); addNode(head, 1); addNode(head, 2); addNode(head, 3); addNode(head, 3); addNode(head, 4); addNode(head, 4); printList(head); head = s.deleteDuplicates(head); printList(head); return EXIT_SUCCESS; }
int main(int argc , char* argv[]) { ListNode* head; ListNode node1(1); ListNode node2(1); ListNode node3(2); //ListNode node4(2); //ListNode node5(3); //ListNode node6(4); //ListNode node7(5); head = &node1; node1.next = &node2; node2.next = &node3; //node3.next = &node4; //node4.next = &node5; //node5.next = &node6; //node6.next = &node7; Solution sol; ListNode* p = sol.deleteDuplicates(head); while(p){ cout<<p->val<<"->"; p = p->next; } cout<<endl; }
int main() { ListNode* node1 = new ListNode(1); ListNode* node2 = new ListNode(2); ListNode* node3 = new ListNode(2); ListNode* node4 = new ListNode(2); ListNode* node5 = new ListNode(3); ListNode* node6 = new ListNode(3); ListNode* node7 = new ListNode(3); node1->next = node2; node2->next = node3; node3->next = node4; node4->next = node5; node5->next = node6; node6->next = node7; Solution sol; ListNode* head = sol.deleteDuplicates(node1); ListNode* p = head; while (p) { cout << p->val << ' '; p = p->next; } cout << endl; return 0; }
void let_83(){ ifstream fin; fin.open("let_83.txt"); char tempc; int value; ListNode* head; ListNode*temp=NULL; while(fin.peek()!=']'){ fin>>tempc>>value; ListNode* cur=(ListNode*) new ListNode(value); if(temp){ temp->next=cur; temp=cur; }else{ temp=cur; head=cur; } } Solution sol; temp=sol.deleteDuplicates(head); while(temp){ cout<<temp->val<<","; temp=temp->next; } cout<<endl; }
static void runTest(int input[], int length) { ListNode *head = arrayToList(input, length); printListNode(head); Solution solution; solution.deleteDuplicates(head); printListNode(head); }
int main() { ListNode *head1 = new ListNode(1); ListNode *head2 = new ListNode(-2); auto p = head1; auto q = head2; vector<int> vec{ 1,1,};//2 for (auto x : vec) { p->next = new ListNode(x); p = p->next; } p->next = NULL; Solution sol; auto pp = sol.deleteDuplicates(head1); while (pp != NULL) { cout << pp->val << " "; pp = pp->next; } cout << endl; system("pause"); return 0; }
int main(){ Solution so; string line; while(getline(cin,line)){ cout<<list2string(so.deleteDuplicates(string2list(line)))<<endl; } }
int main(int argc, char** argv) { ListNode* head = new ListNode(0); ListNode* p = head; for(int i = 1; i < 10; i++) { ListNode* q = (ListNode*)malloc(sizeof(ListNode)); q->val = i + i%2; q->next = NULL; p->next = q; p = p->next; } /* while(head->next!=NULL) { cout << head->next->val << endl; head = head->next; } */ Solution* solution = new Solution(); ListNode* result = solution->deleteDuplicates(head->next); while(result!=NULL) { cout << result->val << endl; result = result->next; } delete solution; return 0; }
int _tmain(int argc, _TCHAR* argv[]) { Solution S; ListNode List1(1),List2(1); List1.next = &List2; S.deleteDuplicates(&List1); return 0; }
int main() { Solution t; ListNode *head=new ListNode(1); ListNode *n=new ListNode(2); head->next=n; cout<<t.deleteDuplicates(head)<<endl; }
TEST(leetcode_082_remove_duplicates_from_sorted_list_ii, Basic) { Solution *solution = new Solution(); ListNode *head = list_init({1, 2, 3, 3, 4, 4, 5}); ListNode *expected = list_init({1, 2, 5}); ListNode *result = solution->deleteDuplicates(head); EXPECT_TRUE(list_equal(expected, result)); }
int main() { ListNode *head = readList(); Solution s; head = s.deleteDuplicates(head); printList(head); return 0; }
int main(){ char array[] = {'a', 'b', 'c', 'd', 'e'}; ListNode* list = initializeList(array, sizeof(array) / sizeof(array[0])); print(list); Solution solution; ListNode* res = solution.deleteDuplicates(list); print(res); return 0; }
int main() { Solution sol; std::vector<int> tests = {1,1,2,2}; auto input = constructListNode(tests); printListNode(input); auto output = sol.deleteDuplicates(input); printListNode(output); return 0; }
int main() { Solution s; vector<int> test = { 1, 2, 2}; auto l1 = lc_createlist(test, true); auto l2 = s.deleteDuplicates(l1); lc_printlist(l2); system("pause"); return 0; }
int main(int argc, const char * argv[]) { // insert code here... Solution so; ListNode* h = new ListNode(1); h->next = new ListNode(1); h->next->next = new ListNode(2); h = so.deleteDuplicates(h); so.dump(h); return 0; }
int main(int argc, char *argv[]) { ListNode *p = construct(vector<int>{1,2,3,3,3}); Solution sol; ListNode *result = sol.deleteDuplicates(p); for (; result; result = result->next) { cout << result->val << " "; } cout << endl; }
ListNode* test(int *a, int size) { ListNode dummy(0), *p = &dummy; for(int i=0; i<size; i++) { p->next = new ListNode(a[i]); p = p->next; } Solution s; return s.deleteDuplicates(dummy.next); }
int main() { Solution *sol = new Solution(); ListNode *head = new ListNode(20); ListNode *node1 = new ListNode(21); ListNode *node2 = new ListNode(22); head->next = node1; head->next->next = node2; ListNode* new_head = sol->deleteDuplicates(head); print(new_head); }
void test() { Solution so; ListNode *tmp; cout << "N083RmDupSortList:\t"; { ListNode *n0 = new ListNode(1); ListNode *n1 = new ListNode(1); n0->next = n1; ListNode *result0 = so.deleteDuplicates(n0); cout << "[ "; while (result0) { tmp = result0->next; cout << result0->val << " "; delete result0; result0 = tmp; } cout << "] "; } { ListNode *n5 = new ListNode(3), *n4 = new ListNode(2), *n3 = new ListNode(2), *n2 = new ListNode(1), *n1 = new ListNode(1); n1->next = n2; n2->next = n3; n3->next = n4; n4->next = n5; ListNode *result1 = so.deleteDuplicates(n1); cout << "[ "; while (result1) { tmp = result1->next; cout << result1->val << " "; delete result1; result1 = tmp; } cout << "] "; } cout << endl; }
int main() { ListNode *List; build_list(List); cout<<"before:"<<endl; print_list(List); Solution result; result.deleteDuplicates(List); cout<<"after:"<<endl; print_list(List); return 0; }
int main(int argc, char const *argv[]) { Solution so; ListNode *ln=new ListNode(1); ln->next=new ListNode(1); ln->next->next=new ListNode(1); ln->next->next->next=new ListNode(3); ln->next->next->next->next=new ListNode(4); ln->next->next->next->next->next=new ListNode(4); ln->next->next->next->next->next->next=new ListNode(5); ListNode * rs=so.deleteDuplicates(ln); visitListNode(rs); return 0; }
int main() { ListNode a(1),b(1); a.next = &b; // b.next= &c; Solution s; ListNode* ret = s.deleteDuplicates(&a); while(ret) { cout << ret->val << "->"; ret=ret->next; } cout << endl; }
int main() { ListNode* head = new ListNode(1); ListNode* p = head; int a[] = {1, 1}; for (size_t i = 0; i < sizeof(a) / sizeof(int); ++i) { p->next = new ListNode(a[i]); p = p->next; } Solution sol; p = sol.deleteDuplicates(head); print(p); }
int main(int argc, char* argv[]) { int A[5] = {1, 1, 2, 2, 2}; int n = 5; cout << "A[] is: " << endl; copy(A, A+n, ostream_iterator<int>(cout, " ")); cout << endl; Node* head = make_list_from_array(A, n); cout << "List of this array is :" << endl; print_list_node(head); Solution s; head = s.deleteDuplicates(head); cout << "After process List is :" << endl; print_list_node(head); return 0; }
int main() { Solution s; // TreeNode *tn = new TreeNode(1); // TreeNode *tl = new TreeNode(2); // tn->left = tl; // TreeNode *tr = new TreeNode(20); // tn->right = tr; // TreeNode *ttt = new TreeNode(15); // tr->left = ttt; // TreeNode *www = new TreeNode(7); // ttt->right = www; ListNode *myListNode = NULL; cout << s.deleteDuplicates(myListNode) << endl; return 0; }