/**
 * Given a set of elements and an index, this function removes the element at the given index and returns the modified set.
 *
 * @param elements A set of elements.
 * @param index An index to remove the element from the set.
 * @return The modified set after removing the element at the specified index.
 */
fun removeAndModify(elements: MutableSet<String>, index: Int): MutableSet<String> {

    val elementsList = elements.toMutableList()

    if (index < 0 || index >= elementsList.size) {
        throw IndexOutOfBoundsException("Invalid index!")
    }

    elementsList[index] = elementsList[index].capitalize()
    elementsList.removeAt(index)

    return elementsList.toMutableSet()
}
/**
 * Given a set of elements and an index, this function removes the element at the given index and returns the modified set.
 *
 * @param elements A set of elements.
 * @param index An index to remove the element from the set.
 * @return The modified set after removing the element at the specified index.
 */
fun removeAndModify(elements: MutableSet<String>, index: Int): MutableSet<String> {
/**
 * Given a set of elements and an index, this function removes the element at the given index and returns the modified set.
 *
 * @param elements A set of elements.
 * @param index An index to remove the element from the set.
 * @return The modified set after removing the element at the specified index.
 */
fun removeAndModify(elements: MutableSet<String>, index: Int): MutableSet<String> {

    val elementsList = elements.toMutableList()

    if (index < 0 || index >= elementsList.size) {
        throw IndexOutOfBoundsException("Invalid index!")
    }

    elementsList[index] = elementsList[index].capitalize()
    elementsList.removeAt(index)

    return elementsList.toMutableSet()
}