xavier-cai / vscode-leetcode-cpp-debug

Debug support for LeetCode with C++
https://marketplace.visualstudio.com/items?itemName=XavierCai.vscode-leetcode-cpp-debug
MIT License
25 stars 5 forks source link

ListNode Constructor in leetcode-types.h not matches the definition. #16

Open Chen-Shen-Yi opened 3 years ago

Chen-Shen-Yi commented 3 years ago

我在24題看到singly-linked list 的方法為

/*Definition on Leetcode*/
struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

但 leetcode-types.h 中只有

/*leetcode-types.h*/
class ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(nullptr) {}
};

另外101題TreeNode 定義

/*Definition on Leetcode*/
struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

也和 leetcode-types.h 中不一致

/*leetcode-types.h*/
struct TreeNode : public mem::PtrObject {
public:
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

目前是手動修改不影響使用

xavier-cai commented 3 years ago

Hi,我想了解一下如果不手动修改,会遇到什么样的问题呢?比如说,是无法使用想要的构造函数吗:TreeNode(int x, TreeNode *left, TreeNode *right)