classSolution { funfindMinArrowShots(points: Array<IntArray>): Int { val pointList: MutableList<IntArray> = points.toMutableList() pointList.sortBy{it[0]} var cnt = 0 var end: Int var tmp: IntArray var it: Iterator<IntArray> while (!pointList.isEmpty()) { it = pointList.iterator() end = pointList[0][1] while (it.hasNext()) { tmp = it.next() if (tmp[0] <= end) { end = Math.min(end, tmp[1]) it.remove() } else { break } } cnt++ } return cnt } }