Find Pivot Index | Leetcode 724 Solution | Searching and Sorting

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


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

Didi 's way of teaching is op.Thankyou pepcoding.

aakashgoswami
Автор

Fantastic explanation 👍thanks a lot mam🙏

shang_chi
Автор

Thank you so much really it's helpful for us.

RajuSingh-rmyx
Автор

Thanks didi . the way of explanation just awesome.

madlegends
Автор

why my code saying wrong answer?

class Solution {
public:
int pivotIndex(vector<int>& nums) {

int size=nums.size();
int Left=0;
int Right=0;

for(int i=0; i<size;i++)
{
Right+=nums[i];
}

for(int i=0; i<size; i++)
{

Right=Right-nums[i];

if(left==right)
return i;

Left+=nums[i];
}

return -1;
}
};

paulbarsha
Автор

That was clean and precise
thank you

abhilash
Автор

can we write the if condition after calculating the updated value of lsum and rsum?

hahahaha
Автор

An explanation is great but kindly discuss TC & SC of each problem.

nageshwankhade
Автор

can pivot index be first and last index of array??
like a[0], a[n-1]?

varunsinghal
Автор

Explanation was really good.but TC and SC not mentioned... only optimal approach discussed

adil