It is best not to define global or static variables outside the class. This will affect your test results, because the test cases all use this piece of code. (Probably it just included this class file).
The correct approach is to add member variables to the class and initialize them in the default constructor.
For other related questions, please see the official FAQ.
leetcode requires you to write a function to complete the specified requirements, and the others have already been written. Not all codes have to be written by yourself
It is best not to define global or static variables outside the class. This will affect your test results, because the test cases all use this piece of code. (Probably it just included this class file).
The correct approach is to add member variables to the class and initialize them in the default constructor.
For other related questions, please see the official FAQ.
https://leetcode.com/faq/
leetcode requires you to write a function to complete the specified requirements, and the others have already been written. Not all codes have to be written by yourself