From 9be57dc6f002ea63a2081ed28125ac0f0d520b8c Mon Sep 17 00:00:00 2001 From: YDZ Date: Thu, 21 Mar 2019 07:48:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20problem=20143?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../143. Reorder List.go | 13 +++++++++++++ .../143. Reorder List_test.go | 0 .../README.md | 0 3 files changed, 13 insertions(+) rename Algorithms/{143.Reorder List => 143. Reorder List}/143. Reorder List.go (86%) rename Algorithms/{143.Reorder List => 143. Reorder List}/143. Reorder List_test.go (100%) rename Algorithms/{143.Reorder List => 143. Reorder List}/README.md (100%) diff --git a/Algorithms/143.Reorder List/143. Reorder List.go b/Algorithms/143. Reorder List/143. Reorder List.go similarity index 86% rename from Algorithms/143.Reorder List/143. Reorder List.go rename to Algorithms/143. Reorder List/143. Reorder List.go index 2fae72a9..9fef7121 100644 --- a/Algorithms/143.Reorder List/143. Reorder List.go +++ b/Algorithms/143. Reorder List/143. Reorder List.go @@ -64,3 +64,16 @@ func reorderList_1(head *ListNode) *ListNode { } return head } + +func listToArray(head *ListNode) []int { + array := []int{} + if head == nil { + return array + } + cur := head + for cur != nil { + array = append(array, cur.Val) + cur = cur.Next + } + return array +} diff --git a/Algorithms/143.Reorder List/143. Reorder List_test.go b/Algorithms/143. Reorder List/143. Reorder List_test.go similarity index 100% rename from Algorithms/143.Reorder List/143. Reorder List_test.go rename to Algorithms/143. Reorder List/143. Reorder List_test.go diff --git a/Algorithms/143.Reorder List/README.md b/Algorithms/143. Reorder List/README.md similarity index 100% rename from Algorithms/143.Reorder List/README.md rename to Algorithms/143. Reorder List/README.md