DataLane

4. ReLU

easyNot started~5 minPythonImplement relu()

Asked in screens shaped like: Google, Meta

Implement relu(x): return the element-wise maximum of x and 0. Return a list of floats.

Examples

  • Example 1

    Input: { "x": [-2, 0, 3] }
    Output: [0, 0, 3]

Constraints

  • 1 <= n <= 10**5, where n is the length of the input
  • Input is non-empty

Python editor

Loading Python engine…

Ctrl/Cmd + Enter submits

Run your code to see stdout.

↑↓ navigate openesc close