# Math problems brainpicking

A list of mathematical programming problems.

## Currency palindrome¶

Difficulty: Medium Required Knowledge: Mathemathics and combinatorics

Description: Given an array of currency denominations, find the highest value of possible coins before you can exchange them exactly for the paper note.

Problem Statement: Complete the highestCoinValue function in the editor below. It must return the highest value of possible coin values before you can exchange them exactly for the paper note as a float.

highestCoinValue has the following parameter(s): ar: an array of floats

Input Format: The first line contains the number of n elements in the array. The second line contains the list of n currency denominations space-separated, out of which all represent the coin values, except for the last value in an array which represents the lowest paper note value, floats contained in the array.

Constraints: 0 < ar[i] < ar[n]

Output Format: Print the highest value of possible coin denominations of the array's elements as a single float.

Time Complexity: O(n)

Approach: Count all the coin denominator values, up to the maximal sum before it is possible to exchange it for the lowest paper note.

Keywords: palindrome, currency

In [2]:
#!/bin/python3

#
# Complete the 'highestCoinValue' function below.
#
# The function is expected to return a FLOAT.
# The function accepts FLOAT_ARRAY ar as parameter.
#

def highestCoinValue(ar):
# Find the highest value of possible coins before you can exchange them exactly for the paper note

Put your code here