Ad
  • Custom User Avatar

    That's because your solution does not handle the specified kind of input. In input you have no numbers, the mountains are given literally as a map filled with ^. Look at the sampel tests, and the example input:

        char[][] mountain = {
          "^^^^^^        ".toCharArray(),
          " ^^^^^^^^     ".toCharArray(),
          "  ^^^^^^^     ".toCharArray(),
          "  ^^^^^       ".toCharArray(),
          "  ^^^^^^^^^^^ ".toCharArray(),
          "  ^^^^^^      ".toCharArray(),
          "  ^^^^        ".toCharArray()
        };      
        assertEquals(3, Dinglemouse.peakHeight(mountain));
    

    Your solution should handle a map of mountains and deduce the numbers.

  • Custom User Avatar
    ```java
    public static int peakHeight(char[][] mountain) {
        int maxValue = Integer.MIN_VALUE;
        for(int i = 0;i<mountain.length;i++){
            for (int j = 0;j<mountain[i].length;j++) {
                char c = mountain[i][j];
                if (c != ' ' && c != '^') {
                    Integer integer = Integer.parseInt(String.valueOf(c));
                    if (maxValue < integer) {
                        maxValue = integer;
                    }
                }
            }
        }
        return maxValue;
    }
    
    
    public static void main(String[] args) {
            char[][] mountain = {
                    "111111        ".toCharArray(),
                    " 12222111     ".toCharArray(),
                    "  1233211     ".toCharArray(),
                    "  12321       ".toCharArray(),
                    "  12332111111 ".toCharArray(),
                    "  122211      ".toCharArray(),
                    "  1111        ".toCharArray()
            };
        System.out.println(peakHeight(mountain));
        }
    }
    
  • Custom User Avatar

    We don't know. We would have to see your code to know.

  • Custom User Avatar

    when I solve a problem in an IDEA, and put the ^ numbers in place manually,
    the solution turns out correctly,
    it turns out 3, but when I run it in codewars the answer is -
    expected:<3> but was:<-2147483648>
    why?

  • Custom User Avatar

    BEST KATA EVER !!!!!!!!!!!!!!!!!

  • Custom User Avatar

    самое простое и понятное решение, именно такие должны быть в коде, сложные решения через стримы крутые, но они слишком замороченные и могут быть с ошибками

  • Custom User Avatar

    гениально