https://leetcode.com/problems/most-visited-sector-in-a-circular-track/description/ Easy

Решение

class Solution {
    fun mostVisited(n: Int, rounds: IntArray): List<Int> {
        val start = rounds[0]
        val end = rounds[rounds.size - 1]
        val res = ArrayList<Int>()
        if (start <= end) {
            var i = start
            while (i <= end) {
                res.add(i)
                i++
            }
        } else {
            var i = 1
            while (i <= end) {
                res.add(i)
                i++
            }
            i = start
            while (i <= n) {
                res.add(i)
                i++
            }
        }
        return res
    }
}