/**
 * Given a list of top artists and their respective ratings, find the artist with the highest rating.
 * If two or more artists have the same rating, return null.
 *
 * @param topArtists List of artists' names as strings.
 * @param artistRatings Map where the keys are artists' names and the values are their ratings.
 * @return The name of the artist with the highest rating, or null if multiple artists have the same rating.
 */
fun findBestArtist(topArtists: List<String>, artistRatings: Map<String, Double>): String? {

    var highestRating = Double.NEGATIVE_INFINITY
    var bestArtist: String? = null

    for (artist in topArtists) {
        val rating = artistRatings.getOrDefault(artist, 0.0)

        if (rating > highestRating) {
            highestRating = rating
            bestArtist = artist
        } else if (rating == highestRating) {
            bestArtist = null
        }
    }

    return bestArtist
}
/**
 * Given a list of top artists and their respective ratings, find the artist with the highest rating.
 * If two or more artists have the same rating, return null.
 *
 * @param topArtists List of artists' names as strings.
 * @param artistRatings Map where the keys are artists' names and the values are their ratings.
 * @return The name of the artist with the highest rating, or null if multiple artists have the same rating.
 */
fun findBestArtist(topArtists: List<String>, artistRatings: Map<String, Double>): String? {
/**
 * Given a list of top artists and their respective ratings, find the artist with the highest rating.
 * If two or more artists have the same rating, return null.
 *
 * @param topArtists List of artists' names as strings.
 * @param artistRatings Map where the keys are artists' names and the values are their ratings.
 * @return The name of the artist with the highest rating, or null if multiple artists have the same rating.
 */
fun findBestArtist(topArtists: List<String>, artistRatings: Map<String, Double>): String? {

    var highestRating = Double.NEGATIVE_INFINITY
    var bestArtist: String? = null

    for (artist in topArtists) {
        val rating = artistRatings.getOrDefault(artist, 0.0)

        if (rating > highestRating) {
            highestRating = rating
            bestArtist = artist
        } else if (rating == highestRating) {
            bestArtist = null
        }
    }

    return bestArtist
}