開發平台(Platform): (Ex: Win10, Linux, ...)
MacOS Sierra
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
XCode
問題(Question):
Run code and submit solution 結果不同
餵入的資料(Input):
[-1,0,1,0]
預期的正確結果(Expected Output):
[[-1,0,1]]
錯誤結果(Wrong Output):
[]
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/tQbV4UCZ
補充說明(Supplement):
LeetCode 15. 3Sum
放到LeetCode上run code 與 submit solution結果不同,點進問題解說中看到
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.
這段英文有看沒有懂,有大大可以指教嗎?
感謝指教