In this lecture, we cover the key Kotlin patterns for traversing an array: iterating by elements and by indexes (
indices), computing the sum and average, counting elements that match a condition, searching for a value with an index returned (
-
1 meaning “not found”), and finding the maximum (both the value alone and the value together with its index). At the end, we review common mistakes (integer division, incorrect accumulator initialization, wrong index bounds, and loss of readability).