What if upper < nums[n-1]?


  • 0
    K

    This problem does not indicate that upper should be less or equal than the last element in nums.
    I've tried a case as below:

    Your input
    [1,3,5,8]
    1
    4

    Expected answer
    ["2","4","6->7"]

    I think the correct answer should be ["2", "4"].
    It seems there is not such case in the test set.


  • 0

    Quite right to question it. The question should be worded better, but I think "where the range of elements are [lower, upper] inclusive" means that the input will always be bound by lower and upper. It probably should say something like "where the range of elements are in the inclusive range [lower, upper]".


  • 0

    @alexbowe Thanks, I have revised the description based on your comment.


Log in to reply
 

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