marcinmoskala
10/23/2020, 6:54 AMmarcinmoskala
10/23/2020, 6:55 AMelizarov
10/23/2020, 7:44 AMMutableList as a queue. You’ll get O(n) removes from the queue. Use ArrayDeque . Also, instead of remoteAt(0) you can write removeFirst().nkiesel
10/23/2020, 8:44 AMMichael de Kaste
10/23/2020, 11:06 AMfun main(){
fibonacci(13U).let(::println)
}
private fun fibonacci(input: UInt) : BigInteger = memoizationMap.getOrPut(input){
fibonacci(input - 1U) + fibonacci(input - 2U)
}
private val memoizationMap = mutableMapOf(0U to BigInteger.ZERO, 1U to BigInteger.ONE)Colton Idle
10/23/2020, 12:22 PMbezrukov
10/23/2020, 12:24 PMDmitry Kandalov
10/23/2020, 4:02 PMDmitry Kandalov
10/23/2020, 4:09 PMMutableList and Array are the ones I normally try to avoid if possible.Colton Idle
10/24/2020, 9:05 PMbezrukov
10/26/2020, 8:43 AM