Skip to main content
454, Four Sum II

I Problem

Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:

  • 0 <= i, j, k, l < n
  • nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0

MikeAbout 1 minhashtablemediumarrayhash table
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
1, Two Sum

I Problem

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.


MikeAbout 1 minhashtableeasyarrayhash table
202, Happy Number

I Problem

Write an algorithm to determine if a number n is happy.

A happy number is a number defined by the following process:

  • Starting with any positive integer, replace the number by the sum of the squares of its digits.
  • Repeat the process until the number equals 1(where it will stay), or it loops endlessly in a cycle which does not include 1.
  • Those numbers for which this process ends in 1 are happy.

MikeAbout 1 minhashtableeasyhash tablemathtwo pointers
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
349, Intersection of Two Arrays

I Problem

Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.

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


MikeAbout 1 minhashtableeasyarrayhash tablebinary searchsortingtwo pointers
438, Find All Anagrams in a String

I Problem

Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.


MikeAbout 2 minhashtablemediumhash tablestringsliding window
49, Group Anagrams

I Problem

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

Example 1
Input: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
Output: [["bat"], ["nat", "tan"], ["ate", "eat", "tea"]]


MikeAbout 1 minhashtablemediumarrayhash tablestringsorting
2