Menu
Coddy logo textTech

Recap - Search a Page

Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 83 of 93.

challenge icon

Challenge

Medium

Read a list length, that many integers, a skip count, a page size, and a target integer, each on its own line. Drop the skipped elements, take up to the page size, and print that page in Kotlin list format. Then print Found if the target occurs within the page, otherwise Missing. Length is 0-20; skip and page size are nonnegative and may exceed the list length.

Try it yourself

fun main() {
    val n = readLine()!!.toInt()
    val values = mutableListOf<Int>()
    for (i in 1..n) values.add(readLine()!!.toInt())
    val skip = readLine()!!.toInt()
    val size = readLine()!!.toInt()
    val target = readLine()!!.toInt()
    // Select the page and search within it.
}

All lessons in Fundamentals

Practice on your own: Kotlin playground