[Kotlin] Two sorts - simple and short
Approach\nUse two sorted arrays - one by end time, the other by by value (highest first).\n\nThen, we iterate through the events sorted by end time. We keep an 
# Approach\nUse two sorted arrays - one by end time, the other by by value (highest first).\n\nThen, we iterate through the events sorted by end time. We keep an index pointing to the current element in the events sorted by value, advancing it to the highest possible event not overlapping with the events iterated over so far.\n\n# Complexity\n- Time complexity: $$O(n \u22C5 log(n))$$\n- Space complexity: $$(O(n))$$\n\n# Code\n```kotlin []\nclass Solution {\n    fun maxTwoEvents(events: Array<IntArray>): Int {\n        val sortedByEnd = events.sortedBy {it[1]}\n        val sortedByValue = events.sortedBy {-it[2]}\n        var ans = 0\n        var i = 0\n        for (a in sortedByEnd) {\n            ans = maxOf(ans, a[2])\n            while (i < sortedByValue.size && sortedByValue[i][0] <= a[1]) i++\n            if (i < sortedByEnd.size) ans = maxOf(ans, a[2] + sortedByValue[i][2])\n        }\n        return ans\n    }\n}\n```
['Kotlin']