Given an array of non-negative integers numbers, check whether the elements at even positions are monotonic.
The even-positioned elements are numbers[0], numbers[2], numbers[4], and so on. They are monotonic if they are either strictly increasing or strictly decreasing.
Return "increasing" if the even-positioned elements are strictly increasing, "decreasing" if they are strictly decreasing, or "none" if they are not monotonic.
A solution with time complexity not worse than O(numbers.length^2) fits within the execution time limit.
numbers = [12, 65, 15, 72, 19, 72] return = "increasing"
Elements at even positions are numbers[0], numbers[2], and numbers[4], i.e. 12, 15, and 19. Since 12 < 15 < 19, the answer is "increasing".
numbers = [12, 1, 54, 5, 19, 14] return = "none"
Elements at even positions are numbers[0], numbers[2], and numbers[4], i.e. 12, 54, and 19. These values are not monotonic, so the answer is "none".
numbers = [666, 17, 66, 5, 6, 23] return = "decreasing"
Elements at even positions are numbers[0], numbers[2], and numbers[4], i.e. 666, 66, and 6. Since 666 > 66 > 6, the answer is "decreasing".
numbersis an array of non-negative integers.
- Count Alternating Tile GroupsOA · Seen Jun 2026
- Count Even-Digit NumbersOA · Seen Jun 2026
- Inventory Discount TrackerOA · Seen Jun 2026
- Construct WDL StringOA · Seen Jun 2026
- Find Sum PairsOA · Seen Jun 2026
- LRU Cache with TTL ExpirationONSITE INTERVIEW · Seen May 2026
- Maximum Candies with At Most Two Types in a LineONSITE INTERVIEW · Seen May 2026
- Top-K KOLs by Total LikesONSITE INTERVIEW · Seen May 2026
public String solution(int[] numbers) {
// write your code here
}