Recap - Search a Page
Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 83 of 93.
Challenge
MediumRead 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
4Operators Part 1
Arithmetic OperatorsModulo OperatorAugmented AssignmentComparison OperatorsRecap - Simple Math7Basic IO
Println FunctionString TemplatesReadLine InputType ConversionRecap - Years Until RetirementRecap - True or False10Functions
Declare A FunctionParameters And ArgumentsReturn ValuesNamed ArgumentsDefault ValuesSingle Expression FunctionsRecap - Sigma FunctionRecap - Validation Function2Variables
Val vs VarType InferenceNumbersStringBooleanNaming ConventionsRecap - Initialize Variables5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Logical Operators Part 3Ternary With If ExpressionRecap - Simple Logic8Bill Split Calculator
Welcome MessageGetting Input14Lists Advanced
List Slicing With SubListList Slicing With Take DropSequence OperatorsThe Contains MethodRecap - Search a Page3Nullability
What Is Null SafetyNullable TypesSafe Call OperatorElvis OperatorFunction Challenge BasicsNot Null AssertionRecap - Safe Access6Decision Making
If StatementIf - ElseIf As An ExpressionWhen ExpressionWhen With RangesRecap - Simple Calculator9Loops
For LoopWhile LoopDo-While LoopBreakContinueRanges In LoopsNested LoopRecap - FactorialRecap - Dynamic InputPractice on your own: Kotlin playground