Compiler does not actually check for division operator

  • 10
    return dividend / divisor;

    was accepted.

  • 8

    Congrats Sherlock, that was good investigation work.

    More seriously: this website is for preparing technical interviews. If you don't want to follow the rules, that your problem. And how do you say to the compiler: please reject all code that use *, /, and so on?

  • 1

    I was merely stating a simple observation, I'm sorry if it came across as offending to anybody. I am of course more than grateful to the people who made this website freely available.

    An implication of the auto judge not fully checking the requirements of the problem is that the AC rate numbers might be inflated, if anybody cared.

    As for how one might implement this check, for Java you could patch the class, such that after the AST is generated you do a simple tree walk to look for the offending operators. This could be done as a preprocessing step to reject non-conforming submissions, after which the real compiler is invoked to generate the actual executable. A fair amount of added burden for sure, but far from impossible.

Log in to reply

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