Leetcode 396. Rotate Function

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

legendary intro, masterful explanation, GANGGGG!!

whatuphere
Автор

I'm with the gang gang gang gang, boys hoppin out the coupe

prathamsharma
Автор

Thankyou sir god bless you

Here is the c++ code O(n):

class Solution {
public:
int array) {
int n = array.size();
int prevsol = 0; int arraysum = 0;
for(int i=0;i<n; i++){
prevsol = prevsol+(i*array[i]);
arraysum = arraysum+array[i];
}

int maxsum = prevsol;
for(int i=n-1; i>=1; i--){
prevsol = prevsol + arraysum - (n*array[i]);
if(maxsum<prevsol){
maxsum = prevsol;
}
}
return maxsum;
}
};

chinmaypanchal
Автор

love the college professor part.
need more

MOHITRANA-torf
Автор

great explanation. btw what board are you using?

preetu
join shbcf.ru