diff --git a/Peaks.java b/Peaks.java index 272cc37..4d1e537 100644 --- a/Peaks.java +++ b/Peaks.java @@ -23,7 +23,8 @@ public int solution(int[] A) { } // 2) check the number of Blocks - int N = A.length; + // Max number of blocks can't exceed peaks count, so that all have at least 1 peak + int N = peaksIndexList.size(); // from the "biggest possible number" to smaller number for(int numBlocks =N; numBlocks >=1; numBlocks--){