Algorithm · Capital One · Medium
Examples Example 1 Example 2 Requirements You receive an integer array nums[] representing the heights of houses. A move raises exactly one array element by 1; lowering an element is unavailable in this version. Once every move is complete, the array must match one of these exact patterns: consecutive ascending values with nums[i+1] = nums[i] + 1, or consecutive descending values with nums[i+1] = nums[i] - 1. Find the fewest operations needed among those two possible final…
Checking your access…