[Suggestion] [C++] Compile out assertions in final solution


  • 0

    It seems that assert statements are compiled when I submit a solution to a problem, which hurts the runtime in case complex assertions are used. I would prefer if the assertions were enabled when I "Run Code" but disabled when I "Submit Solution".
    Assertions can be disabled by defining the macro NDEBUG before including <cassert>. Details:

    As a workaround, I redefine the assert macro in the beginning of my code when I want to disable the assertions:

    #undef assert
    #define assert(x)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.