Split an array into two equal Sum subarrays| gfg potd | 18-08-24 | GFG Problem of the day

preview_player
Показать описание
Geeks for Geeks Problem of the Day(POTD) in C++ | Split an array into two equal Sum subarrays | Fully Explained🧠

Solution Code :

IMPORTANCE OF DSA FOR PLACEMENT:

🌐 Connect with Me:

#GFG #POTD #geeksforgeeks #problemoftheday #c++
Рекомендации по теме
Комментарии
Автор

Alternate Solution :

bool canSplit(vector<int>& arr) {
// code here
int i = 0, j = arr.size()-1, lhs = arr[i], rhs = arr[j];
while(i < j){
if(lhs == rhs && j-i == 1)return true;
else if(lhs > rhs){j--;rhs+=arr[j];}
else {i++;lhs+=arr[i];}
}
return false;
}

printfiamd
Автор

Great...coded by myself just by hearing the initial 2 statements of the explanation

anushkachavan
join shbcf.ru