java - 我对 Leetcode 问题的解决方案在调试区域产生了结果,但在提交页面中给出了编译错误
问题描述
我为 leetcode 中的问题(最小大小子数组总和)创建了一个解决方案,它在我的笔记本电脑中运行,即使在 leetcode 调试区域(产生结果),但在提交页面中出现编译错误。谁能告诉我是什么导致了这个编译错误和解决方法?
下面是我得到的编译错误:(突出显示第 10 行,即使第 10 行似乎与此错误无关)
第 10 行:错误:不兼容的类型:int 无法转换为 Integer[] [在Driver .java 中]
class Solution {
static int size=0;
static int wsize=0;
static int indic =0;
public static int minSubArrayLen(Integer[] arr, int res){
int st=0;
for(int j=0;j<arr.length;j++){
int a=arr[j];
if(a==6){
(Line no:10) size=1;
indic =1;
return size;
}
st=st+arr[j];
if(st==res){
wsize=j+1;
break;
}
if(st>6){
wsize= j;
break;
}
} return wsize;
}
public static int compare(int wsize, Integer[] arr,int res){
int ans=0;
for(int i =1;i<arr.length;i++){
if(arr[i]==res){
size=1;
return size;
}
wsize= (wsize-1)+i;
for(int k=i;k<wsize-1;k++){
ans=ans+arr[k];
if(ans>res){
break;
}
if(res==6){
size=(k+1)-i;
}
}
}
return size;
}
public static void main(String[] args) {
//Integer[] arr = {1,5,7,9,-2,6,3,9};
Integer[] arr = {1,5,7,9,-2,3,9};
int res=6;
size=minSubArrayLen(arr, res);
if(size!=0 && indic==0){
size=compare(size,arr,res);
}
System.out.println(size);
}
}
解决方案
推荐阅读
- java - 在一系列偏移量之间从 Kafka 主题读取消息
- vba - 无法在输入框中输入范围
- excel - 删除 AM/PM,但保留 12h 格式
- forms - 在 Flutter 中填写完表单中的所有字段后关闭键盘?
- python - 如何在python中将时间和时区转换为日期?
- typescript - TypeScript 从其他项目绝对导入普通 TS 文件和全局范围声明
- protocol-buffers - 如何在 gRPC 中使用标量类型作为函数参数?
- visual-studio-code - 删除触摸栏上预配置的 VSCode 按钮
- reactjs - 创建 React App - 无法获取本地颁发者证书
- c# - 如何执行 Graphql 查询?