Is there a limit to the length of the code, if so what's the limit number?


  • 2
    L

    i submit my solution with a total of 294 lines. then it says"Your code is too long. Please reduce your code size and try again."
    My code is loaded with a lot of switch cases,that's why it grows so big, is there any tricks to write a neat finite state machine code?


  • 0
    L

    Since this is the first topic for the quote: "Your code is too long. Please reduce your code size and try again.".

    Suggestions (although the fact that you hit the limit implies there is a more succinct solution):

    • In non-whitespace languages, highlight all of your code and press Shift+Tab a few times to remove a ton of whitespace.
    • Remove all access modifiers for functions
    • Remove all comments
    • Remove curly braces and the newline from single-line code blocks.
    • Use automatic specification of variables (auto/var)`

Log in to reply
 

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