1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
sort-array-by-parity-ii.py 362 Bytes
Copy Edit Raw Blame History
# Time: O(n)
# Space: O(1)
class Solution(object):
def sortArrayByParityII(self, A):
"""
:type A: List[int]
:rtype: List[int]
"""
j = 1
for i in xrange(0, len(A), 2):
if A[i] % 2:
while A[j] % 2:
j += 2
A[i], A[j] = A[j], A[i]
return A
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search