From 9dbfa4502dc3213218fbea94f6ef0946be5da26d Mon Sep 17 00:00:00 2001 From: X-shuffle <53906918+X-shuffle@users.noreply.github.com> Date: Wed, 7 Jul 2021 23:09:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=200491.=E9=80=92=E5=A2=9E?= =?UTF-8?q?=E5=AD=90=E5=BA=8F=E5=88=97=20go=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 0491.递增子序列 go版本 --- problems/0491.递增子序列.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/problems/0491.递增子序列.md b/problems/0491.递增子序列.md index 85c9d307..103b8b10 100644 --- a/problems/0491.递增子序列.md +++ b/problems/0491.递增子序列.md @@ -257,6 +257,34 @@ class Solution: Go: +```golang +func findSubsequences(nums []int) [][]int { + var subRes []int + var res [][]int + backTring(0,nums,subRes,&res) + return res +} +func backTring(startIndex int,nums,subRes []int,res *[][]int){ + if len(subRes)>1{ + tmp:=make([]int,len(subRes)) + copy(tmp,subRes) + *res=append(*res,tmp) + } + history:=[201]int{}//记录本层元素使用记录 + for i:=startIndex;i0&&nums[i]