8000 Total Runtime: 225 ms · michaelhuang/LintCode_Python@7b35d5f · GitHub
[go: up one dir, main page]

Skip to content

Commit 7b35d5f

Browse files
committed
1 parent f4d741c commit 7b35d5f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Partition_Arr_by_Odd_Even.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
# @param nums: a list of integers
3+
# @return: nothing
4+
def partitionArray(self, nums):
5+
odds, evens = [], []
6+
for i in nums:
7+
evens.append(i) if i & 1 == 0 else odds.append(i)
8+
nums[:] = [] # empty the list
9+
nums.extend(odds)
10+
nums.extend(evens)
11+
12+
13+
if __name__ == '__main__':
14+
a = Solution()
15+
a1 = [2147483644, 2147483645, 2147483646, 2147483647]
16+
a.partitionArray(a1)
17+
print a1

0 commit comments

Comments
 (0)
0