乱人伦 国语对白海角社区,五月激情丁香婷婷综合中文字幕,欧美伊人婷婷久久五月综合,亚洲精品无amm毛片,亚洲男人第一无码AV网站,国产日韩欧美丝袜一区二区,亚洲一区精品在线观看

LeetCode移动零-huluwain官网app

LeetCode移动零

2026-01-19 02:54:21投稿人:樂魚網(wǎng)站 贊助大巴黎(鎮(zhèn)江)有限公司圍觀21663 評論

LeetCode移動零

給定一個數(shù)組 nums,編寫一個函數(shù)將所有 0 移動到數(shù)組的末尾 ,同時(shí)保持非零元素的相對順序 。

說明:

  1. 必須在原數(shù)組上操作 ,不能拷貝額外的數(shù)組。
  2. 盡量減少操作次數(shù)。
void moveZeroes(int* nums, int numsSize){     int count = 0, length = numsSize-1;    while (length >= 0) {         if(nums[length] == 0) {             count++;//計(jì)數(shù)            int temp = length;            while (temp < numsSize-1) {                 nums[temp] = nums[temp+1];                temp++;            }        }            length--;    }    while (count >0) {         nums[numsSize-count] = 0;        count--;    }}

官方答案