Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 538 Bytes

File metadata and controls

16 lines (13 loc) · 538 Bytes

Problem 14: Quartic Combination (4Sum)

Problem Statement

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, d are distinct.
  • nums[a] + nums[b] + nums[c] + nums[d] == target You may return the answer in any order.

Input Format

  • An array of integers nums.
  • An integer target.

Example

Input: nums = [1, 0, -1, 0, -2, 2], target = 0
Output: [[-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1]]