按奇偶排序数组
2025-4-20
| 2025-4-20
Words 227Read Time 1 min
type
status
date
slug
summary
tags
category
icon
password
给你一个整数数组 nums,将 nums 中的的所有偶数元素移动到数组的前面,后跟所有奇数元素。
返回满足此条件的 任一数组 作为答案。
来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/SNJvJP 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
示例 1:
示例 2:
提示:
  • 1 <= nums.length <= 5000
  • 0 <= nums[i] <= 5000

思路:

  • 遍历两遍数组

代码:

结果:

notion image
image-20220428215000605
排列硬币拿硬币
Loading...