add new solutions
This commit is contained in:
parent
9a10695e8c
commit
ca24d0a56a
30 changed files with 697 additions and 16 deletions
18
solutions/2/q206/solution.go
Normal file
18
solutions/2/q206/solution.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package q206
|
||||
|
||||
type ListNode struct {
|
||||
Val int
|
||||
Next *ListNode
|
||||
}
|
||||
|
||||
func reverseList(head *ListNode) *ListNode {
|
||||
var prev, current *ListNode = nil, head
|
||||
for current != nil {
|
||||
next := current.Next
|
||||
current.Next = prev
|
||||
prev, current = current, next
|
||||
}
|
||||
return prev
|
||||
}
|
||||
|
||||
var _ = reverseList
|
||||
17
solutions/2/q283/solution.go
Normal file
17
solutions/2/q283/solution.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package q283
|
||||
|
||||
func moveZeroes(nums []int) {
|
||||
p := 0
|
||||
for i := range nums {
|
||||
if nums[i] == 0 {
|
||||
continue
|
||||
}
|
||||
nums[p] = nums[i]
|
||||
p++
|
||||
}
|
||||
for i := p; i < len(nums); i++ {
|
||||
nums[i] = 0
|
||||
}
|
||||
}
|
||||
|
||||
var _ = moveZeroes
|
||||
Loading…
Add table
Add a link
Reference in a new issue