funcmax(a,b int)int{if a>b{return a
}return b
}funcfindLengthOfLCIS(nums []int)int{
n:=len(nums)
maxlen:=0for l:=0;l<n;l++{
r:=l+1for r<n&&nums[r]>nums[r-1]{
r++}
maxlen=max(r-l,maxlen)}return maxlen
}
cpp
intfindLengthOfLCIS(vector<int>& nums){int n = nums.size();int maxlen =0;for(int l =0; l < n; l++){int r = l +1;while(r < n && nums[r]> nums[r -1]){
r++;}
maxlen =max(r - l, maxlen);}return maxlen;}
funcmax(a, b int)int{if a > b {return a
}return b
}functotalFruit(nums []int)int{
cnt:=map[int]int{}
maxlen:=0
l:=0for r,x:=range(nums){
cnt[x]++forlen(cnt)>2{
y:=nums[l]
cnt[y]--if cnt[y]==0{delete(cnt,y)}
l++}
maxlen=max(maxlen,r-l+1)}return maxlen
}
问题情况 : 主要问题 : 调用lua执行redis时,有一个值会接受nil(因为redis中没有该数据)或者数值,当该值为nil时执行报错,因为会用到将该值与其他数字比较,故报错attempt to compare nil with number 当然…