-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.cpp
40 lines (37 loc) · 946 Bytes
/
template.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
#include "leetcode.hpp"
using namespace std;
class Solution{
public:
//method which return thing
vector<vector<int>> method1(vector<int> &nums){
//do your stuff
return vector<vector<int>>();
}
//method that use the pass in value as resurlt
void method2(vector<int> &nums){
//do something with nums
}
//method that work with TreeNode (Work same for ListNode)
TreeNode* method3(TreeNode* root){
return root;
}
};
int main(){
Solution s;
vector<int> nums1,nums2;
TreeNode * root;
//method1
cin >> nums1;
cout << s.method1(nums1);
//method2
cin >> nums2;
s.method2(nums2);
cout << nums2;
//method3
cin >> root;
//ListNode work same as TreeNode require the conversion before TreeNode
TreeNode outnode = *s.method3(root);//Cannot use TreeNode* directly, as the address will be output if use TreeNode*
cout << outnode;
return 0;
}