65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
#include <iostream>
|
|
|
|
#include "1-two-sum.cpp"
|
|
#include "2-add-two-numbers.cpp"
|
|
#include "9-palindrome-number.cpp"
|
|
#include "13-roman-to-integer.cpp"
|
|
|
|
int main() {
|
|
TwoSumSolution twoSumSolution;
|
|
auto v = std::vector<int>{11, 2, 8, 0, 35, 7, 15};
|
|
auto res = twoSumSolution.twoSum(v, 9);
|
|
std::cout << "Result: ";
|
|
for (auto index : res) {
|
|
std::cout << index << " ";
|
|
}
|
|
std::cout << std::endl;
|
|
|
|
AddTwoNumbersSolution addTwoNumbersSolution;
|
|
ListNode *l1 = new ListNode(2);
|
|
l1->next = new ListNode(4);
|
|
l1->next->next = new ListNode(3);
|
|
|
|
ListNode *l2 = new ListNode(5);
|
|
l2->next = new ListNode(6);
|
|
l2->next->next = new ListNode(4);
|
|
auto resList = addTwoNumbersSolution.addTwoNumbers(l1, l2);
|
|
std::cout << "addTwoNumbers: ";
|
|
ListNode *listPtr = resList;
|
|
while (listPtr) {
|
|
std::cout << listPtr->val << " ";
|
|
listPtr = listPtr->next;
|
|
}
|
|
std::cout << std::endl;
|
|
|
|
ListNode *l3 = new ListNode(9);
|
|
l3->next = new ListNode(9);
|
|
l3->next->next = new ListNode(9);
|
|
l3->next->next->next = new ListNode(9);
|
|
l3->next->next->next->next = new ListNode(9);
|
|
l3->next->next->next->next->next = new ListNode(9);
|
|
l3->next->next->next->next->next->next = new ListNode(9);
|
|
|
|
ListNode *l4 = new ListNode(9);
|
|
l4->next = new ListNode(9);
|
|
l4->next->next = new ListNode(9);
|
|
l4->next->next->next = new ListNode(9);
|
|
|
|
resList = addTwoNumbersSolution.addTwoNumbers(l3, l4);
|
|
std::cout << "addTwoNumbers: ";
|
|
listPtr = resList;
|
|
while (listPtr) {
|
|
std::cout << listPtr->val << " ";
|
|
listPtr = listPtr->next;
|
|
}
|
|
std::cout << std::endl;
|
|
|
|
PalindromeNumberSolution p;
|
|
std::cout << "Is 1 palindrome? " << p.isPalindrome(1) << std::endl;
|
|
|
|
RomanToIntegerSolution r;
|
|
std::cout << "MCMXCIV = " << r.romanToInt("MCMXCIV") << std::endl;
|
|
|
|
return 0;
|
|
}
|