https://www.codewars.com/kata/how-many-stairs-will-suzuki-climb-in-20-years/train/java

import java.util.Arrays;

public class Kata
{
    public static long stairsIn20(int[][] stairs)
    {
        return 20 * Arrays.stream(stairs).flatMapToInt(arr -> Arrays.stream(arr)).sum();
    }
}

 

My Solution :

    public static long stairsIn20(int[][] stairs) {
        long result = 0;

        for (int i = 0; i < stairs.length; i++) {
            for (int j = 0; j < stairs[i].length; j++) {
                result += stairs[i][j];
            }
        }
        return result * 20;
    }

 

相关文章:

  • 2021-05-30
  • 2021-12-03
  • 2021-11-06
  • 2022-01-08
  • 2022-01-14
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2021-05-31
  • 2022-02-10
相关资源
相似解决方案