Skip to content

Bug Report for python-min-max-shortcut #5419

@jeffreycrum

Description

@jeffreycrum

Bug Report for https://neetcode.io/problems/python-min-max-shortcut

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

Here is the description:

Challenge
Implement the following functions:

disallow_negatives(num: int) -> int that takes an integer and returns the integer if it is greater than or equal to 0. Otherwise, it should return 0.
max_difference(nums: List[int]) -> int that takes a list of integers and returns the maximum difference between any two adjacent elements in the list, by subtracting the element on the right from the element on the left. In other words, it should return the maximum value of nums[i] - nums[i - 1] for all valid indices i.
You may assume the output will always be a positive integer.
Example: Given the list [10, 1, 3, 7], the maximum adjacent difference is 7 - 3 = 4.
You may assume all input lists will have at least two elements.

The issue is the description is wrong. by subtracting the element on the right from the element on the left. In other words, it should return the maximum value of nums[i] - nums[i - 1] for all valid indices i. The answer is actually subtracting the element on the left (current index) from the element on the right nums[i + 1] - nums[I]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions