將演算法
public static int findLengthOfLCIS(int[] nums) {
if (nums.length == 0)
return 0;
int max = 0;
int count = 1;
for (int i = 0; i < nums.length - 1; i++) {
if (nums[i] < nums[i + 1]) {
count++;
} else {
max = Math.max(count, max);
count = 1;
}
}
max = Math.max(count, max);
return max;
}改為回傳 list 的上下標(index)陣列(如遇相同長度回傳較大index的陣列)
uj5u.com熱心網友回復:
public static List<Integer> maxsubIndexOfLCIS(int[] nums) {List<Integer> res = new ArrayList<Integer>();
if ( nums.length < 2) {
return null;
}
if (lnums.length== 2) {
if (nums[i] < nums[i + 1]) {
res.add(0);
res.add(1);
return res;
} else {
return res;
}
}
.....
uj5u.com熱心網友回復:
沒有人能搞定嗎?uj5u.com熱心網友回復:
改成 javascript 也行啊轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/46393.html
標籤:JavaScript
