/**
 * Given a list of integers and a target integer, find the index of the target if it exists.
 *
 * However, be cautious of infinite loops!
 */
fun findInfiniteLoops(list: List<Int>, target: Int): Int {

    var left = 0
    var right = list.size - 1

    while (left <= right) {
        val mid = (left + right) / 2

        if (list[mid] == target) {
            return mid
        }

        if (list[mid] < target) {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }

    return -1  // If the target is not found in the list
}
/**
 * Given a list of integers and a target integer, find the index of the target if it exists.
 *
 * However, be cautious of infinite loops!
 */
fun findInfiniteLoops(list: List<Int>, target: Int): Int {
/**
 * Given a list of integers and a target integer, find the index of the target if it exists.
 *
 * However, be cautious of infinite loops!
 */
fun findInfiniteLoops(list: List<Int>, target: Int): Int {

    var left = 0
    var right = list.size - 1

    while (left <= right) {
        val mid = (left + right) / 2

        if (list[mid] == target) {
            return mid
        }

        if (list[mid] < target) {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }

    return -1  // If the target is not found in the list
}