/**
 * Determines whether a pet ID exists in the veterinarian's records using the number line representation.
 *
 * @param vetRecords List of pet IDs in the veterinarian's records.
 * @param petId The ID of the pet to search for.
 * @return True if the pet ID exists in the records, False otherwise.
 */
fun numberLineComparison(vetRecords: List<Int>, petId: Int): Boolean {

    var vetRecordsSorted = vetRecords.sorted() // Sort the records to ensure easy comparison

    var lo = 0
    var hi = vetRecordsSorted.size - 1

    while (lo <= hi) {
        val mid = (lo + hi) / 2

        when {
            vetRecordsSorted[mid] == petId -> return true
            vetRecordsSorted[mid] > petId -> hi = mid - 1
            else -> lo = mid + 1
        }
    }

    return false
}
/**
 * Determines whether a pet ID exists in the veterinarian's records using the number line representation.
 *
 * @param vetRecords List of pet IDs in the veterinarian's records.
 * @param petId The ID of the pet to search for.
 * @return True if the pet ID exists in the records, False otherwise.
 */
fun numberLineComparison(vetRecords: List<Int>, petId: Int): Boolean {
/**
 * Determines whether a pet ID exists in the veterinarian's records using the number line representation.
 *
 * @param vetRecords List of pet IDs in the veterinarian's records.
 * @param petId The ID of the pet to search for.
 * @return True if the pet ID exists in the records, False otherwise.
 */
fun numberLineComparison(vetRecords: List<Int>, petId: Int): Boolean {

    var vetRecordsSorted = vetRecords.sorted() // Sort the records to ensure easy comparison

    var lo = 0
    var hi = vetRecordsSorted.size - 1

    while (lo <= hi) {
        val mid = (lo + hi) / 2

        when {
            vetRecordsSorted[mid] == petId -> return true
            vetRecordsSorted[mid] > petId -> hi = mid - 1
            else -> lo = mid + 1
        }
    }

    return false
}