Skip to content

add Kotlin#4

Open
davy-tw wants to merge 1 commit intoc910335:masterfrom
davy-tw:kotlin
Open

add Kotlin#4
davy-tw wants to merge 1 commit intoc910335:masterfrom
davy-tw:kotlin

Conversation

@davy-tw
Copy link

@davy-tw davy-tw commented Oct 13, 2017

No description provided.

main.kt Outdated
repeat(n - 1) { i ->
print(" ${ranks[i + 1]}")
}
println("")
Copy link
Owner

@c910335 c910335 Oct 13, 2017

Choose a reason for hiding this comment

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

How about println(ranks.joinToString(" "))?

Copy link
Author

Choose a reason for hiding this comment

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

good!

@davy-tw davy-tw force-pushed the kotlin branch 2 times, most recently from a663121 to 56e32ca Compare October 16, 2017 14:39
@davy-tw
Copy link
Author

davy-tw commented Oct 16, 2017

Updated with insertion sort mentioned in #7

}

fun findRank(ranks: IntArray, points: MutableList<Point>) : List<Point> {
if (points.size <= 1) return points
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary

Copy link
Author

Choose a reason for hiding this comment

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

No, this is necessary for avoiding re-layout a ArrayList below (Line 55), this can be more efficiently in Kotlin.

Copy link
Owner

Choose a reason for hiding this comment

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

But it never get into this since points.size <= THRESHOLD cover this condition.

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