← ALL NOTES
Array

2460. Apply Operations to an Array

Given nums, sweep left to right: if nums[i] == nums[i+1], double nums[i] and zero nums[i+1]. After all operations, shift all zeros to the end, preserving the order of non-zeros. Return the result.…

Loading…