01/10/2018, 08:16
Ai giúp mình về Challenge in Codefight với

Đề: Như vậy
Còn Mã:
`int adjacentElementsProduct(std::vector inputArray) {
int result=inputArray[0]*inputArray[1];
int N=sizeof(inputArray)/sizeof(int);
int val;
for (int i=1;i<N-1;++i){
val=inputArray[i]*inputArray[i+1];
if (val>result) result=val;
}
return result;
}
`
Cho mình hỏi là còn thiếu sót j ko vậy mà mình ko wa 1 hidden test của nó.
Bài liên quan
Tràn số. Đảm bảo luôn.
Với lại prototype nên có const và tham chiếu.
Tràn số là sao vậy bạn?
Mà tràn dữ liệu ở chỗ nào vậy b. mình thấy nó nằm trong dữ liệu mà.
Dùng sizeof để tính số lượng phần tử là sai. N=inputArray.size();
Chả hiểu sao thớt đúng 9 test với câu lệnh đó, ảo diệu.