Skip to main content
56, Merge Intervals

I Problem

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.

Example 1
Input: intervals = [[1, 3], [2, 6], [8, 10], [15, 18]]
Output: [[1, 6], [8, 10], [15, 18]]
Explanation: Since intervals [1, 3] and [2, 6] overlap, merge them into [1, 6].


MikeAbout 2 mingreedymediumarraysorting
452, Minimum Number of Arrows to Burst Balloons

I Problem

There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons.


MikeAbout 2 mingreedymediumarraygreedysorting
406, Queue Reconstruction by Height

I Problem

You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the iᵗʰ person of height hi with exactly ki other people in front who have a height greater than or equal to hi.


MikeAbout 2 mingreedymediumbinary indexed treesegment treearraysorting
1005, Maximize Sum Of Array After K Negations

I Problem

Given an integer array nums and an integer k, modify the array in the following way:

  • choose an index i and replace nums[i] with -nums[i].

You should apply this process exactly k times. You may choose the same index i multiple times.


MikeAbout 2 mingreedyeasygreedyarraysorting
455, Assign Cookies

I Problem

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.

Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.


MikeAbout 2 mingreedyeasygreedyarraytwo pointerssorting
347, Top K Frequent Elements

I Problem

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

Example 1
Input: nums = [1, 1, 1, 2, 2, 3], k = 2
Output: [1, 2]


MikeAbout 4 minstack/queuemediumhash tabledivide and conquersortingheap(priority queue)bucket sortcountingquick select
18, Four Sum

I Problem

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

  • 0 <= a, b, c, d < n
  • a, b, c, and d are distinct.
  • nums[a] + nums[b] + nums[c] + nums[d] == target

MikeAbout 3 minhashtablemediumarraytwo pointerssorting
16, Three Sum Closest

I Problem

Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.

Return the sum of the three integers.

You may assume that each input would have exactly one solution.


MikeAbout 2 minhashtablemediumarraytwo pointerssorting
15, Three Sum

I Problem

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

Notice that the solution set must not contain duplicate triplets.


MikeAbout 2 minhashtablemediumarraytwo pointerssorting
350, Intersection of Two Arrays II

I Problem

Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order .

Example 1
Input: nums1 = [1, 2, 2, 1], nums2 = [2, 2]
Output: [2, 2]


MikeAbout 2 minhashtableeasyarrayhash tablebinary searchsortingtwo pointers
2