Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to sort arrays by parity in leetCode

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

LeetCode in how to sort the array by parity, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

First, sort the array II1 by parity, a brief description of the problem.

Given a non-negative integer array A, half of the integers in An are odd and half of the integers are even.

Sort the array so that when A [I] is odd, I is also odd; when A [I] is even, I is even.

You can return any array that meets the above criteria as an answer.

2. Example description example:

Input: [4, 2, 5, 7]

Output: [4, 5, 5, 2, 7]

Explanation: [4, 7, 2, 5], [2, 5, 5, 4, 7], [2, 7, 4, 5] will also be accepted.

Tip:

two

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 243

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report