All problems
Vector Elementwise Maximum
Problem
Take the elementwise maximum of two equal-length vectors.
Return a list where entry i is max(a[i], b[i]). Ties keep the value from a, which only matters for the exact comparison.
Hint
Compare paired entries and keep the larger one.
Test cases
case 1
in: [[1,2,3],[4,0,3]]
expected: [4,2,3]
case 2
in: [[-1,-5],[-2,-3]]
expected: [-1,-3]
case 3
in: [[7],[7]]
expected: [7]
case 4
in: [[2,2],[2,2]]
expected: [2,2]
case 5
in: [[],[]]
expected: []
Starter codePython
def elementwise_max(a, b):
# Your code here
pass5 test cases · run your code against them in the editor