public int search(int[] nums, int target) { int len = nums.length; int i = 0,j = -1; while(i<len){ if(nums[i] == target){ j = i+1; while(j<len){ if(nums[j]!=target){ return j-i; }else{ j++; } } if(j == len) return j-i; }else{ i++; } } return 0; }
2024-01-23 20:32:36
public int search(int[] nums, int target) { int len = nums.length; int i = 0,j = -1; while(i<len){ if(nums[i] == target){ j = i+1; while(j<len){ if(nums[j]!=target){ return j-i; }else{ j++; } } if(j == len) return j-i; }else{ i++; } } return 0; }
下一篇:53