Closed Penguin-SAMA closed 7 months ago
you need to import them at the top so the LSP will be aware of them
But if I add a structure like ListNode
, I can't solve the problem correctly.
LeetCode has it own compiler, whereas you can see ListNode
is already defined.
Just because you are getting an error in your neovim doesn't mean that the test will not pass.
If i remember correctly ListNode
is the only custom struct i came across using LeetCode. For example, if you are using java
, you can create an object inside leetcode.nvim
home directory named ListNode
, solely for auto completion purposes.
I don't know if it will work the same way with cpp
, but you can always uncomment the struct, and then if you are about to run
/submit
, comment it again so it won't clash with the LeetCode compiler.
I know that commenting out the structure allows me to solve the problem correctly, but this looks very inelegant, so I want to ask for a possible solution. However, if it's just ListNode causing this issue, it seems acceptable. Anyway, thank you very much for your patient response.
#include "./ListNode.cpp"
#include <cstddef>
// @leet start
class Solution
{
public:
ListNode *reverseList(ListNode *head)
{
ListNode *prev = NULL;
ListNode *curr = head;
while (curr != NULL)
{
ListNode *forward = curr->next;
curr->next = prev;
prev = curr;
curr = forward;
}
return prev;
}
};
// @leet end
@Penguin-SAMA Now only the code within @leet
tags gets submitted.
So you can do something like
#include "./ListNode.cpp"
to have auto completion from local files or have a place to define a struct.
The latest version seems to no longer display @leet start and @leet end.
Thanks for the report, should be working now
I am using C++, how can I fix the issue where![image](https://github.com/kawre/leetcode.nvim/assets/50973632/2612a81f-b2d4-4144-8664-8d0b7ea5a6f1)
vector
andListNode
are not recognized? Can it only be done manually?