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 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() {
    Solution sol;
    std::vector<int> tests = {1,2,3,4,5};
    auto headA = constructListNode(tests);
    auto headB = constructListNode(std::vector<int>{7,8});
    headB->next->next = headA->next;

    auto res = sol.getIntersectionNode_2(headA, headB);
    printListNode(res);
    return 0;
}
Esempio n. 4
0
int main()
{
	vector<int> v = { 1, 2, 3, 4, 5, 6 };
	ListNode *head = new ListNode(v[0]);
	ListNode *p = head;
	for (auto i = next(v.begin()); i != v.end(); i++, p = p->next)
		p->next = new ListNode(*i);

	head = rotateRight(head, 3);
	printListNode(head);

	system("pause");
	return 0;
}
int main() {
    Solution sol;
    std::vector<std::vector<int>> tests = {
            {}
            , {1,2,3,3}
            , {1,2,3}
            , {1,1,1,1,1}
            , {1,1,2,2}
            , {1,2,2,3}
            , {1,1,2,3}
    };

    for (auto const& test : tests) {
        auto input = constructListNode(test);
        std::cout << "before: ";
        printListNode(input);
        auto res = sol.deleteDuplicates(input);
        std::cout << "after: ";
        printListNode(res);
        std::cout << std::endl;
    }

    return 0;
}
Esempio n. 6
0
int main() {
    ListNode n1(1);
    ListNode n2(2);
    ListNode n3(3);
    ListNode n4(4);

    n1.next = &n2;
    n2.next = &n3;
    n3.next = &n4;

    Solution sln;

    sln.reorderList(&n1);

    printListNode(&n1);

    return 0;
}