Leetcode 525. Contiguous Array | Hashing | Leetcode Daily Challenge

preview_player
Показать описание
Check out our other playlists:

Dynamic Programming:

Trees:

Heaps and Maps:

Arrays and Maths:

Bit Manipulation:

Greedy Algorithms:

Sorting and Searching:

Strings:

Linked Lists:

Stack and Queues:

Two Pointers:

Graphs, BFS, DFS:

Backtracking:

Non- DSA playlists:

Probability:

SQL-Basic Join functions:

SQL-Basic Aggregate functions:
Рекомендации по теме
Комментарии
Автор

int sum =0;
int ans = 0;
unordered_map<int, int>m;
m.insert({0, -1});
for(int i=0;i<nums.size();i++)
{
sum+=nums[i]==1?1:-1;
auto it = m.find(sum);
if(it!=m.end())
{
ans = max(ans, i-it->second);
}
else m.insert({sum, i});

}

return ans;

probabilitycodingisfunis
Автор

Already solved the question . But came to watch your approach for better understanding :) Happy coding :)

rydham
Автор

Alisha, I love your explaination much

zeyadalbadawy
Автор

you deserves a salute, very awesome approach, can we also try this one with sliding window approach?

AmanSharma-vbjl
Автор

can you provide the link for the mic you are using?

factnoted
Автор

good explanation,
can you add your linkedin profile in your description area,
it would be great for all who wanted to reach out to you!

anshulbansal