Merge Intervals | leetcode 56 | Company tag : Facebook , Amazon, Google
🔴 Code - http://thecodingworld.com/2020/06/01/merge-intervals/
🔴 Struggling solving leetcode question give yourself a 5 min break ➡️➡️ https://youtu.be/X1TgX0eoevM
🔴 TheCodingWorld is an initiative to give back to the community, We have started this channel to aid the student community to grasp different topics in computer science, with appropriate examples, particularized and comprehensive explanation.
The majority of our videos are about programming and interview preparation.
🔴 If you haven’t you should join our community
⬇⬇⬇⬇⬇⬇⬇
✅ 🤳🏻 📲 👨🏫 💬for early updates and Announcement 📢 - https://t.me/joinchat/AAAAAE6R3PLTMJWx05NvLg
✅ chat with me (Telegram)👨🏫💬 - https://t.me/joinchat/Lvim3BNQhw1wVPFOFSn09A
✅INSTAGRAM - https://instagram.com/thecodingworld?igshid=89hpqrtn8c7h
✅📬📧 Email - info.thecodingworld@gmail.com
problem description 📄📖
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
Example 2:
Input: [[1,4],[4,5]]
Output: [[1,5]]
Explanation: Intervals [1,4] and [4,5] are considered overlapping.
Solution 📝
1) Sort all intervals in increasing order of start time.
2) Traverse sorted intervals starting from first interval,
3)Check if current interval overlaps with previous interval ( if starting of current is less or equal to ending of previous)
a) If current interval overlaps with previous interval, then merge it with previous interval (by updating the previous starting as {min(starting of previous, starting of current interval)} and ending as{ max(ending of previous, starting of current)}
b) Remove the current interval
4) return the intervals.
Resources 📖🗃
leetcode - https://leetcode.com/problems/merge-intervals/
if this video helped you in anyway please give it a thumbs up and subscribe for more such videos.
Видео Merge Intervals | leetcode 56 | Company tag : Facebook , Amazon, Google канала thecodingworld
🔴 Struggling solving leetcode question give yourself a 5 min break ➡️➡️ https://youtu.be/X1TgX0eoevM
🔴 TheCodingWorld is an initiative to give back to the community, We have started this channel to aid the student community to grasp different topics in computer science, with appropriate examples, particularized and comprehensive explanation.
The majority of our videos are about programming and interview preparation.
🔴 If you haven’t you should join our community
⬇⬇⬇⬇⬇⬇⬇
✅ 🤳🏻 📲 👨🏫 💬for early updates and Announcement 📢 - https://t.me/joinchat/AAAAAE6R3PLTMJWx05NvLg
✅ chat with me (Telegram)👨🏫💬 - https://t.me/joinchat/Lvim3BNQhw1wVPFOFSn09A
✅INSTAGRAM - https://instagram.com/thecodingworld?igshid=89hpqrtn8c7h
✅📬📧 Email - info.thecodingworld@gmail.com
problem description 📄📖
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
Example 2:
Input: [[1,4],[4,5]]
Output: [[1,5]]
Explanation: Intervals [1,4] and [4,5] are considered overlapping.
Solution 📝
1) Sort all intervals in increasing order of start time.
2) Traverse sorted intervals starting from first interval,
3)Check if current interval overlaps with previous interval ( if starting of current is less or equal to ending of previous)
a) If current interval overlaps with previous interval, then merge it with previous interval (by updating the previous starting as {min(starting of previous, starting of current interval)} and ending as{ max(ending of previous, starting of current)}
b) Remove the current interval
4) return the intervals.
Resources 📖🗃
leetcode - https://leetcode.com/problems/merge-intervals/
if this video helped you in anyway please give it a thumbs up and subscribe for more such videos.
Видео Merge Intervals | leetcode 56 | Company tag : Facebook , Amazon, Google канала thecodingworld
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
LeetCode 56. Merge Intervals (Algorithm Explained)Google | Facebook technical Interview question | TWO SUM | PYTHONpossible bipartition | possible bipartiton leetcode python | leetcode 886Arraylist | Merge Intervals | Google | InterviewBit | Lecture 39subarray sum equals k leetcode | subarray sum equal to k python | amazon interview questionThree Sum| 3Sum | Google | Facebook | Interview Question| PYTHON | leetcodeBinary Search : Median of two sorted arrays of different sizes.Maximum Subarray | leetcode 53 | 30-Day LeetCoding Challenge day 3 | leetcode python solutionAMAZON CODING INTERVIEW QUESTION - WORD SEARCH (LeetCode)Amazon interview question Merge K sorted list | leetcode 23 | python solutionConstruct binary search tree from preorder traversal | Leetcode #1008Numbers of Islands leetcode python | number of islands python |google interview question | leetcodeinterval list intersections leetcode | interval list intersection python | leetcode 986 | $$find all anagrams in a string python | find all anagrams in a string leetcode python | leetcode 438Total Ways in Matrix Dynamic Programmingcheapest flights within k stops leetcode | cheapest flights within k stops python | leetcode 787Parking Lot - System Design Interview Question(Remade) First Missing Positive | Arrays | Leetcode 41花花酱 LeetCode 56. Merge Intervals - 刷题找工作 EP85