Hi, I am trying this problem <https://try.kotlinla...
# getting-started
s
Hi, I am trying this problem https://try.kotlinlang.org/#/Examples/Problems/Index%20of%20Maximum/Index%20of%20Maximum.kt Here is my code
Copy code
package maxindex

fun indexOfMax(a: IntArray): Int? {
    if (a.isEmpty())
    	return null
    return a.indexOf(a.max()!!)
}
I am getting all tests passed except
testIndexOfMaximum6
and
testIndexOfMaximum7
. I can't find the bug. Pls help
m
sjthn: I think the test expects the last index with the maximum value. Try using
lastIndexOf
instead of
indexOf
.
👍 1
s
Oh yes that's right. Thanks @marstran
tests passed 💯