Absolute value sum of a list of integers in Python

This technical problem deals with finding the sum of the absolute values of a list of integers in Python. An example input is given, along with the expected output.

Problem

Given a list of integers, write a Python function to return the sum of the absolute values of the numbers in the list.
Example input: [3, -4, 2, -5]
Example output: 14

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by elrichendelgart
def sum_abs(lst):
    return sum(map(abs, lst))

# This is optimal because it uses the built-in sum function, which is O(n) and the built-in map function, which is also O(n).
# The abs function is also O(1) so the overall complexity is O(n).

A.I. Evaluation of the Solution

This is a great solution! The candidate has correctly identified the built-in functions to use and has correctly identified the time complexity of the solution.

Evaluated at: 2022-11-08 21:04:04