Skip to content

Conversation

@RamazanovSham
Copy link

No description provided.

return intArrayOf(i, j)
}
}
throw IllegalArgumentException()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исключение выбрасывается, если пара не найдена. Можно еще добавить сообщение типа: IllegalArgumentException("No two numbers sum to target")

TODO("Выполните задание")
} No newline at end of file
val n = numbers.size
for (i in 0..n-1){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут можно использовать until для полуоткрытых интервалов: 0 until n и i+1 until n вместо 0..n-1 и i+1..n-1
until явно показывает, что конец не включается. Это стандартная практика в Kotlin для итерации по индексам.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants