乌海市网站建设_网站建设公司_数据统计_seo优化
2025/12/31 3:26:00 网站建设 项目流程

一、数组与矩阵

1、把数组中的 0 移到末尾

283. Move Zeroes (Easy)

Leetcode / 力扣

For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
public void moveZeroes(int[] nums) { int idx = 0; for (int num : nums) { if (num != 0) { nums[idx++] = num; } } while (idx < nums.length) { nums[idx++] = 0; } }

2、改变矩阵维度

566. Reshape the Matrix (Easy)

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询