Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How LeetCode adjusts the array order so that odd numbers precede even numbers

Shulou Source: shulou.com Published: 2022-06-01 13:07:26 10月02日 Update

This article mainly introduces LeetCode how to adjust the array order to make the odd number in front of the even number, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand it.

Title

Enter an array of integers and implement a function to adjust the order of the numbers in the array so that all odd numbers are in the first half of the array and all even numbers are in the second half of the array.

Example: input: nums = [1rect 2je 3je 4] output: [1meme 3je 2je 4] Note: [3jre 1je 2je 4] is also one of the correct answers. Tip: 1

Tags: Array even odd article order adjustment pointer input both ends code value interest function front half half at the same time ideas points numbers integers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi MariaDB Huawei NVidia