LeetCode中runcode结果和sublime结果不一致的原因

来源:互联网 发布:网站cms系统 编辑:程序博客网 时间:2024/05/16 15:52

很有可能是设置了全局变量的原因。

官方解释:

First, please check if you are using any global or static variables. They are Evil, period. If you must declare one, reset them in the first line of your called method or in the default constructor. Why? Because the judger executes all test cases using the same program instance, global/static variables affect the program state from one test case to another. See this Discuss thread for more details.

根据以上提示,修改代码,尽量不使用全局变量

阅读全文
0 0
原创粉丝点击