2025 iThome 鐵人賽
分享至
題目介紹
解題成功圖片:
notion筆記截圖:
延伸解法(直接搬移非零值):
for (int i = 0; i < nums.length; i++) {if (nums[i] != 0) {int temp = nums[i];nums[i] = nums[nonZeroIndex];nums[nonZeroIndex] = temp;
nonZeroIndex++; }
}}
IT邦幫忙