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 countMaxFloodFill(colors: Array<IntArray>): Int { | |
var best = 0 | |
val counts = arrayOfNulls<AtomicInteger?>(colors.size) | |
colors.forEachIndexed { y, rows -> | |
rows.forEachIndexed { x, color -> | |
// get the current count from the neighbour above or to the left of the current cell if either have the same color. | |
// If above and left have the same color, check if they are connected, if they are not, we can connect them and add them together. | |
val leftIsSameColor = colors.getOrNull(y)?.getOrNull(x - 1) |
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
import java.util.*; | |
public class Averages { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
Mean mean = new Mean(); | |
GeometricMean geometricMean = new GeometricMean(); | |
Median<Double> median = new Median<>((a, b) -> (a + b) / 2); |
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
import android.support.annotation.NonNull; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.RandomAccess; | |
import java.util.Set; | |
/** | |
* Created by andy on 14/08/15. |