diff --git a/problems/0406.根据身高重建队列.md b/problems/0406.根据身高重建队列.md index bd27b1b2..3c6ee63c 100644 --- a/problems/0406.根据身高重建队列.md +++ b/problems/0406.根据身高重建队列.md @@ -222,7 +222,7 @@ class Solution: ``` Go: -```golang +```go func reconstructQueue(people [][]int) [][]int { //先将身高从大到小排序,确定最大个子的相对位置 sort.Slice(people,func(i,j int)bool{ @@ -241,7 +241,38 @@ func reconstructQueue(people [][]int) [][]int { return result } ``` +```go +//链表法 +func reconstructQueue(people [][]int) [][]int { + sort.Slice(people,func (i,j int) bool { + if people[i][0]==people[j][0]{ + return people[i][1]people[j][0] + }) + l:=list.New()//创建链表 + for i:=0;i