Merge Intervals - Leetcode 56 - Arrays & Strings (Python)

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


Please check my playlists for free DSA problem solutions:

My Favorite Courses:

Data Structures & Algorithms:

Python:

Web Dev / Full Stack:

Cloud Development:

Game Development:

SQL & Data Science:

Machine Learning & AI:
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

Great work! Wondering why we can't just initiate merged as merged = [intervals[0]]

I feel like that's more readable and that way we don't need the "if not merged" check each time. Thanks!

kishc
Автор

I just couldnt figure out the need for the .max but examples like this make it necessary:

intervals = [[1, 5], [2, 6], [3, 4]]

Powaup
Автор

thanks! Is intervals.sort() not sufficent? and why not?

helloworldcsofficial