given N lockers with width , height, length and a single package with length,height ,width , find the min locker that the package can be stored in.
2. find the exact sizes for the package if given that the package has to be put in the locker with its exact dimensions.
קלט מערך של מספרים ופלט מערך של מספרים שבכל תא מכפלת האיברים חוץ מהתא הספציפי
תשובות
הוסף תשובה
|
לצפיה בתשובות
מרץ 2024
Prefix/suffix multiplication
מאי 2024
ב - O(N)
להכפיל את כל המספרים במערך, ולמלא את מערך בתוצאת ההכפלה לחלק למספר הנוכחי במערך המקורי
ספטמבר 2024
להזהר מהאפסים.
צריך להיות משהו כזה:
ֿvector function(vector arr)
{
int mult = 0;
list zero_list;
for (int i = 0; i++; i< arr.length)
{
if arr[i] == 0
{
zero_list.add[i];
}
else
mult = mult * arr[i];
}
vector new_arr; // should be zeros at the initlize
if !zero_list.is_empty() {
if zero_list.length() == 1
new_arr[list.get()] = mult;
return new_arr;
}
for (int i = 0; i++; i< arr.length)
{
new_arr[i] = mult / arr[i];
}
return new_arr;
}