You are currently viewing Useful Kotlin short-hands for DS/A problems?

Useful Kotlin short-hands for DS/A problems?

I prefer to use Kotlin to solve data structures and algorithms questions online. ( it helps me kill two birds with one stone) and I recently found a really useful short-hand for maintaining a frequency map.

val countMap = someVar.groupingBy{it}.eachCount()

I also use apply , any, slice and window really often.

Are there any other such tricks and tips that make life easier?

submitted by /u/srini_kini
[link] [comments]