Golang Leetcode 922. Sort Array By Parity II.go
2019-04-20 10:28
363 查看
版权声明:原创勿转 https://blog.csdn.net/anakinsun/article/details/89413815
思路
按照题意解决
code
func sortArrayByParityII(A []int) []int { if len(A) == 0 { return []int{} } ret := make([]int, len(A)) a, b := 0, 1 for _, v := range A { if v%2 == 0 { ret[a] = v a += 2 } else { ret[b] = v b += 2 } } return ret }
更多内容请移步我的repo:https://github.com/anakin/golang-leetcode
相关文章推荐
- Golang Leetcode 713. Subarray Product Less Than K.go
- Golang Leetcode 714. Best Time to Buy and Sell Stock with Transaction Fee.go
- Golang Leetcode 868. Binary Gap.go
- Golang Leetcode 926. Flip String to Monotone Increasing.go
- Golang Leetcode 977. Squares of a Sorted Array.go
- Golang Leetcode 123. Best Time to Buy and Sell Stock III.go
- Golang Leetcode 985. Sum of Even Numbers After Queries.go
- Golang Leetcode 445. Add Two Numbers II.go
- Golang Leetcode 1005. Maximize Sum Of Array After K Negations.go
- Golang Leetcode 131. Palindrome Partitioning.go
- Golang Leetcode 956. Tallest Billboard.go
- Golang Leetcode 142. Linked List Cycle II.go
- Golang Leetcode 961. N-Repeated Element in Size 2N Array.go
- Golang Leetcode 173. Binary Search Tree Iterator.go
- Golang Leetcode 965. Univalued Binary Tree.go
- Golang Leetcode 1022. Sum of Root To Leaf Binary Numbers.go
- Golang Leetcode 260. Single Number III.go
- Leetcode 709. 转换成小写字母 golang go 语言
- go/golang 中的import
- GO_05_2:Golang 中 panic、recover、defer 的用法