/**
 * Given a list of accounts, calculate the total expenses by summing up the negative amounts.
 *
 * @param accounts A list of transaction amounts
 * @return The total expenses
 *
 * Example:
 * calculateTotalExpenses(listOf("$100", "-$50", "$200", "-$75")) // -125.0
 */
fun calculateTotalExpenses(accounts: List<String>): Double {

    var totalExpenses = 0.0

    // Iterate over each account in the list
    for (account in accounts) {
        val amount = account.replace("$", "").toDouble()  // Extract the numerical value from the account string

        // Check if the amount is negative (i.e., an expense)
        if (amount < 0) {
            totalExpenses += amount
        }
    }

    return totalExpenses
}
/**
 * Given a list of accounts, calculate the total expenses by summing up the negative amounts.
 *
 * @param accounts A list of transaction amounts
 * @return The total expenses
 *
 * Example:
 * calculateTotalExpenses(listOf("$100", "-$50", "$200", "-$75")) // -125.0
 */
fun calculateTotalExpenses(accounts: List<String>): Double {
/**
 * Given a list of accounts, calculate the total expenses by summing up the negative amounts.
 *
 * @param accounts A list of transaction amounts
 * @return The total expenses
 *
 * Example:
 * calculateTotalExpenses(listOf("$100", "-$50", "$200", "-$75")) // -125.0
 */
fun calculateTotalExpenses(accounts: List<String>): Double {

    var totalExpenses = 0.0

    // Iterate over each account in the list
    for (account in accounts) {
        val amount = account.replace("$", "").toDouble()  // Extract the numerical value from the account string

        // Check if the amount is negative (i.e., an expense)
        if (amount < 0) {
            totalExpenses += amount
        }
    }

    return totalExpenses
}