Last active
November 24, 2020 13:22
-
-
Save DineshSolanki/a668ece008e9eec424d681345acec3b7 to your computer and use it in GitHub Desktop.
Kotlin Extension function to find index of minimum value of given row of 2D array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Array<DoubleArray>.minIndexOfColumnsOfRow(rowNumber: Int): Int { | |
var minNum = this[0][rowNumber] | |
var minIndex = 0 | |
repeat(this.size) | |
{ x -> | |
if (minNum > this[x][rowNumber]) { | |
minIndex = x | |
minNum = this[x][rowNumber] | |
} | |
} | |
return minIndex | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment