Data Stream as Disjoint Intervals - Leetcode 352 - Python

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

Solving today's daily leetcode problem on January 27. This one is tricky, but not too bad for a leetcode hard problem.

0:00 - Read the problem
0:30 - Drawing Explanation
6:00 - Coding Explanation

leetcode 352

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

Don't forget to like/subscribe for the YT algorithm, if you find these videos helpful! And I'll try to be consistent with the daily problems! 😀

NeetCodeIO
Автор

This is just so intelligently done! Could understand after adding numerous prints

chandrikasaha
Автор

6:10 My heart stopped...

(Not really I use C++ but still)

scresat
Автор

SortedDict is not a tree by the way, it is python dictionary + SortedList, where SortedList is a list of sorted lists with metadata about maximums and extra logic for even distribution of values

mmaximov
Автор

Neet would you mind making a vid on pros/cons of moving to Seattle for tech? I know that’s kinda random, maybe better for your OG channel but it’s something I’m sure a lot of us wonder.
“Is it worth moving for FAANG”

def__init
Автор

java version:
class SummaryRanges {
private Set<Integer> set;
public SummaryRanges() {
set = new TreeSet<>();
}

public void addNum(int value) {
set.add(value);
}

public int[][] getIntervals() {

List<int[]> res = new ArrayList<>();

for(int n : set)
{
int size = res.size();

if(size > 0 && res.get(size - 1)[1] + 1 == n)
{
res.get(size - 1)[1] = n;
}
else{
res.add(new int[]{n, n});
}
}

return res.toArray(new int[0][]);
}
}

ADITYA-fkzy
Автор

in 1st solution, Can we use a list instead of a set?

aa
welcome to shbcf.ru