可能有一個簡單的答案,但是在練習有關黑客排名的一些問題時,“aScore”并不是說某個值,第一個值a[i]大于b[i]。我一直在嘗試除錯代碼,但我無法在黑客級別的控制臺上列印我想要的內容,它被迫以某種方式出現在答案的輸出中。
public static List<int> compareTriplets(List<int> a, List<int> b)
{
int aScore=0;
for(int i=0; i ==(a.Count-1);i )
if (a[i]>b[i]){
aScore ;
}
return new List<int>(){aScore,1} ;
}
}

uj5u.com熱心網友回復:
for(int i=0; i ==(a.Count-1);i ) 應該 for(int i=0; i < a.Count; i )
只要條件(第二個“部分”)決議為真,for 回圈就會執行和迭代。
在您的原始代碼中,它不:0 不等于 a.Count-1,因此回圈體甚至不會執行一次。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/382196.html
上一篇:Python串列復制指向同一地址
下一篇:列出串列的最后一個值遞增的串列
