bad title/judge


  • 0

    @contributors @awice

    • Title says "Greater Than" but problem is really about "greater than or equal to".
    • Note says nums will have a length in the range [1, 50] but in reality all test cases have at least length 4. That doesn't catch solutions that fail for length 1. Is nobody ensuring that all limits are tested?

  • 0

    @ManuelP Thank you for your comments.

    First, on the title, if the title was "Largest Number Greater Than Or Equal To Twice Of Others" it would be kind of obnoxious. All titles are basically first order approximations of the problem, I don't really see any fault here, but I am open to suggestions - what would you title the problem?

    As for "missing" test cases, the test cases are chosen to efficiently check for incorrect solutions. There are two main factors we consider: correctness, and algorithmic complexity. In problems with low limits (especially easy or easy-medium problems), we are mainly focused on correctness. I think while it is assumed that your code will be tested on the highest and lowest bounds, in 100% of AC solutions, the solution would not have failed if there were cases with array length 1, so I felt the cases were natural and appropriate at doing the job of testing correctness. [edit: guess not]

    As for displaying the "true" bounds of the test cases, I think using the more natural number is better because it is not a red herring and draws less suspicion around those numbers. For example we basically always use 0 or 1 for the bottom end of a range. Using a bound like "[7, 50]" would draw unwanted attention to the 7. This kind of matters because in some problems eg. the alphabet size is <= 4 which draws your attention to solutions that make use of that fact.


  • 0

    @awice said in bad title/judge:

    obnoxious

    :-D

    How about "Largest Number At Least Twice of Others"?

    in 100% of AC solutions, the solution would not have failed if there were cases with array length 1

    Did you actually check that? Or is that just a conjecture? I had submitted one yesterday that got accepted and would've failed with length 1, so you're wrong about that one. Was like this:

    def dominantIndex(self, nums):
        a, b = sorted(nums)[-2:]
        return nums.index(b) if b >= 2 * a else -1
    

    And I'd say that's a pretty easy mistake to make, at least for beginners. I'd be surprised if really nobody made that mistake. (I admit I didn't do it as mistake but out of curiosity.)

    Edit: Ta-dah... here's someone else's that crashes for length 1: https://discuss.leetcode.com/post/236812

    As for displaying the "true" bounds of the test cases, I think using the more natural number is better

    Yeah, absolutely. I didn't mean that [4, 50] should've been displayed. Definitely keep [1, 50]. I only mentioned that as background for my complaint about the lower limit not being tested.


  • 0

    @ManuelP Hmm okay. I added some test cases :O


  • 0

    @awice Good, thanks. Limits should always be tested. You might not be able to come up with code that fails them, but someone will :-) (Unintentionally, I mean, not just out of curiosity.)


  • 0

    @ManuelP said in bad title/judge:

    How about "Largest Number At Least Twice of Others"?

    Thanks, just fixed.


Log in to reply
 

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