Rearrange int array to put odd number to left and even to right
来源:互联网 发布:ubuntu jdk下载 编辑:程序博客网 时间:2024/06/05 21:05
双指针,左右调换。no extra memory, O(n)
class Solution: def sepOddEven(self, nums): if not nums or len(nums) == 0: return None left = 0 right = len(nums) - 1 while left < right: if nums[left] % 2 == 0: nums[left], nums[right] = nums[right], nums[left] right -= 1 else: left += 1 return nums
0 0
- Rearrange int array to put odd number to left and even to right
- android left-to-right
- left-to-right evaluation rule and side effect
- 328. Odd Even Linked List Add to List
- Int to Roman And Roman to Int
- presentModalViewController animation from left to right
- Reference To Array And Pointer To Array
- simplexml to array and array to xml
- Partition Array by Odd and Even
- Partition Array by Odd and Even
- [Lintcode]Partition Array by Odd and Even
- Partition Array by Odd and Even
- #373 Partition Array by Odd and Even
- LintCode on Array by Odd and Even
- Partition Array by Odd and Even
- python int to binary and count the number of 1
- string to int to double and int double to string
- C# string Array to int Array
- C# 之屏幕找图
- Spring事务的隔离级别
- HashMap的key可以是可变的对象吗???
- Java + myBatis + MySql
- 程序上面,一般不使用 悲观锁
- Rearrange int array to put odd number to left and even to right
- iOS疯狂详解之SQlite数据库增删改查
- Citirx reciever 客户端添加帐户
- LeetCode-Reverse Linked List
- SWERC2014 PRO A
- 深度学习word2vec笔记之算法篇
- *LeetCode-Happy Number
- LeetCode-Ugly Number
- LeetCode-Power of Two