Leetcode 1695. Maximum Erasure Value | Erase a subarray containing unique elements | Sliding Window

preview_player
Показать описание
Use coupon ALISHA on any GeeksforGeeks course to get 10% discount:

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:

Timestamls:
0:00 Reading the problem
1:00 Example 1
4:00 Example 2
11:00 Line by Line Code
Рекомендации по теме
Комментарии
Автор

Code CPP:
int start = 0;
int end = 0;
set<int>s;
int sum =0;
int ans = 0;
while(end<nums.size())
{
while(start<end && s.find(nums[end])!=s.end())
{
s.erase(nums[start]);
sum-=nums[start++];
}

s.insert(nums[end]);
sum+=nums[end++];
ans = max(ans, sum);

}
return ans;

probabilitycodingisfunis
Автор

your Sliding window and two pointer technique is great By previous of some questions solution, I soved todays problem by himself thanks you..

rahulgautam
Автор

your explanation is as beautiful as you are.

umishra
Автор

Runtime comes out to be really large here

mridulsetia
Автор

Hey how to improve logical thinking, I got stuck at subarray problem s

gunahawk
Автор

Hello
(Vector<int>& nums) ye har interview coding round me yesa kuch automatically declare hota hai ...to plz ap ye pata skti hai kya ...aisa kyu hota hai...could you explain about all detail?

harshalijangale
Автор

Longest Substring Without Repeating Characters and that question have same logic but i didn't understand using 0f inner while in that question
please explain anyone.

AnandKumar-oooy
Автор

Ma'am please upload the video of today's potD of GFG

rishavrox
Автор

Very good explanation, please try to tell time and space complexity also.

punityadav
welcome to shbcf.ru