用户:
留梦灵溪查看:0 回复:1 评论:0 创建时间:2023-04-28T16:39:44
力扣原题:https://leetcode.cn/problems/sliding-subarray-beauty/
卡在测试用例334了:[-50,14] 2 2
附go语言出错代码
func getSubarrayBeauty(nums []int, k int, x int) []int {
ll :=len(nums)-k+1
s := make([]int,ll)
for j:=0;j<len(nums)-k+1;j++{//子数组的数量
t1:=nums[j]
c1:=make([]int,x-1)
c3:=0
c4:=1
for a:=0;a<x;a++{
if c4==j&&x>1{
t1=nums[j+1]
}else{
t1=nums[j]
}
for i:=j;i<j+k;i++{//子数组的在原数组中的位置
c3=0
if t1>=nums[i]{//-3,-2,3
for _,c2 :=range c1{
if i==c2{//i
c3=1
}
}
if c3==0{
t1=nums[i]
c4=i
}
}
}
c1 = append(c1,c4)
}
if t1<0{
s[j]=t1
}else{
s[j]=0
}
}
return s
}