about | help | code help+videos | done | prefs |
Mountain, Part IV: public boolean isMountain(int[] nums). Returns true if the values in the array are ordered as a "mountain"; otherwise returns false. For there to be a mountain, all 3 of the following conditions must hold: (1) There must be a peak. (2) The elements to the left of the peak must appear in increasing order. (3) The elements to the right of the peak must appear in decreasing order. Use the 3 methods that your already wrote: isDecreasing(), isIncreasing(), and getPeakIndex(). isMountain([1, 2, 3, 2, 1]) → true isMountain([1, 2, 1, 2, 1]) → false isMountain([1, 2, 3, 1, 5]) → false ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 350
Copyright Nick Parlante 2017 - privacy