class Solution { public: int pivotIndex(vector& nums) { int totalSum = 0; int i = 0; while (i < nums.size()) { totalSum += nums[i]; ++i; } int leftSum = 0; i = 0; while (i < nums.size()) { int rightSum = totalSum - (leftSum + nums[i]); if (leftSum == rightSum) { return i; } leftSum += nums[i]; ++i; } return -1; } };
Sir apse ek chota sa doubt tha ... Like i have no interest in competitive programming but i have intrest in open source o should i prefer java over c++ for placements and internship for upcoming time as i am currently in 3rd sem along with javascript for contributions
Bhai jese factorial ka karte hai wese ek index ke aage ke saare index and pichhe ke saare index ko sum kar de to kesa rahega Like ek main index let 3 in this case, uske pichhe ke saare index i.e 0,1,2 ka sum and aageke saare index ka sum 4,5 agar equal aaya then print karega pivot index
class Solution {
public:
int pivotIndex(vector& nums) {
int totalSum = 0;
int i = 0;
while (i < nums.size()) {
totalSum += nums[i];
++i;
}
int leftSum = 0;
i = 0;
while (i < nums.size()) {
int rightSum = totalSum - (leftSum + nums[i]);
if (leftSum == rightSum) {
return i;
}
leftSum += nums[i];
++i;
}
return -1;
}
};
Awesome
Why have you stopped making videos?
Was on a week vacation for new year. It restarts tomorrow morning.
Good Luck sir! Nice content again..
Happy new year sumeet sir 🎉
Waiting for next videos
Starting today
Hi, Can you please tell which software is this, which you are using for digital writing?
I need that urgently.
Sir apse ek chota sa doubt tha ...
Like i have no interest in competitive programming but i have intrest in open source o should i prefer java over c++ for placements and internship for upcoming time as i am currently in 3rd sem along with javascript for contributions
Awesome ❤
Bhai jese factorial ka karte hai wese ek index ke aage ke saare index and pichhe ke saare index ko sum kar de to kesa rahega
Like ek main index let 3 in this case, uske pichhe ke saare index i.e 0,1,2 ka sum and aageke saare index ka sum 4,5 agar equal aaya then print karega pivot index
Equilibrium point GFG
Yes,why have you stopped? Kindly make it even if there was a gap. RESTART.
Hanji. I will restart today.
Bhaiya kal se video nhi aaya hai😢
Christmas
sir kya hua sde prep band hogayi kya
bhai, 1 week ki chutti pe hun.
1st jan se restart
okk sir
Why have you stopped making videos?