Skip to main content
Became Hot Network Question
added 322 characters in body
Source Link
CrSb0001
  • 479
  • 2
  • 13
# Note: Thank you all for the additional test cases! However,
#       I will not be taking any more at this time just so the
#       question doesn't appear on the [Home] page for too long.
 Array: [-5,-2,-2,1,3,4,6]
Target: 0
Output: [[-5,-2,-2,3,6]]

 Array: [-5,-4,-2,0,1,2,6]
Target: 1
Output: [[-5,-2,0,2,6],[-4,-2,0,1,6]]

# Note that outputting `[[-4,-2,0,1,6],[-5,-2,0,2,6]]` is also valid,
# although returning just `[[-4,-2,0,1,6]]` or `[[-5,-2,0,2,6]]` is not.

 Array: [0,-1,2,3]
Target: 4
Output: -1

 Array: [0,1,-9,6,7]
Target: 6
Output: -1

 Array: [0,1,9,9,5]
Target: 45
Output: -1

 Array: [1,4,6,9,-4]
Target: 16
Output: [[1,4,6,9,-4]]

 Array: [1,0,9,6,5,0]
Target: 21
Output: [[1,0,9,6,5]]

 Array: [1,0,9,6,5,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

 Array: [1,0,9,6,5,4,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7],[0,6,4,4,7],[1,5,4,4,7]]

# Above test case suggested by @Shaggy

 Array: [1,1,2,2,3,3,4,4]
Target: 11
Output: [[1,2,2,3,3],[1,1,2,3,4]]

# Above test case suggested by @Arnauld
 Array: [-5,-2,-2,1,3,4,6]
Target: 0
Output: [[-5,-2,-2,3,6]]

 Array: [-5,-4,-2,0,1,2,6]
Target: 1
Output: [[-5,-2,0,2,6],[-4,-2,0,1,6]]

# Note that outputting `[[-4,-2,0,1,6],[-5,-2,0,2,6]]` is also valid,
# although returning just `[[-4,-2,0,1,6]]` or `[[-5,-2,0,2,6]]` is not.

 Array: [0,-1,2,3]
Target: 4
Output: -1

 Array: [0,1,-9,6,7]
Target: 6
Output: -1

 Array: [0,1,9,9,5]
Target: 45
Output: -1

 Array: [1,4,6,9,-4]
Target: 16
Output: [[1,4,6,9,-4]]

 Array: [1,0,9,6,5,0]
Target: 21
Output: [[1,0,9,6,5]]

 Array: [1,0,9,6,5,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

 Array: [1,0,9,6,5,4,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7],[0,6,4,4,7],[1,5,4,4,7]]

# Above test case suggested by @Shaggy
# Note: Thank you all for the additional test cases! However,
#       I will not be taking any more at this time just so the
#       question doesn't appear on the [Home] page for too long.
 Array: [-5,-2,-2,1,3,4,6]
Target: 0
Output: [[-5,-2,-2,3,6]]

 Array: [-5,-4,-2,0,1,2,6]
Target: 1
Output: [[-5,-2,0,2,6],[-4,-2,0,1,6]]

# Note that outputting `[[-4,-2,0,1,6],[-5,-2,0,2,6]]` is also valid,
# although returning just `[[-4,-2,0,1,6]]` or `[[-5,-2,0,2,6]]` is not.

 Array: [0,-1,2,3]
Target: 4
Output: -1

 Array: [0,1,-9,6,7]
Target: 6
Output: -1

 Array: [0,1,9,9,5]
Target: 45
Output: -1

 Array: [1,4,6,9,-4]
Target: 16
Output: [[1,4,6,9,-4]]

 Array: [1,0,9,6,5,0]
Target: 21
Output: [[1,0,9,6,5]]

 Array: [1,0,9,6,5,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

 Array: [1,0,9,6,5,4,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7],[0,6,4,4,7],[1,5,4,4,7]]

# Above test case suggested by @Shaggy

 Array: [1,1,2,2,3,3,4,4]
Target: 11
Output: [[1,2,2,3,3],[1,1,2,3,4]]

# Above test case suggested by @Arnauld
fixed test case
Source Link
CrSb0001
  • 479
  • 2
  • 13
 Array: [-5,-2,-2,1,3,4,6]
Target: 0
Output: [[-5,-2,-2,3,6]]

 Array: [-5,-4,-2,0,1,2,6]
Target: 1
Output: [[-5,-2,0,2,6],[-4,-2,0,1,6]]

# Note that outputting `[[-4,-2,0,1,6],[-5,-2,0,2,6]]` is also valid,
# although returning just `[[-4,-2,0,1,6]]` or `[[-5,-2,0,2,6]]` is not.

 Array: [0,-1,2,3]
Target: 4
Output: -1

 Array: [0,1,-9,6,7]
Target: 6
Output: -1

 Array: [0,1,9,9,5]
Target: 45
Output: -1

 Array: [1,4,6,9,-4]
Target: 16
Output: [[1,4,6,9,-4]]

 Array: [1,0,9,6,5,0]
Target: 21
Output: [[1,0,9,6,5]]

 Array: [1,0,9,6,5,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

 Array: [1,0,9,6,5,4,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7],[0,6,4,4,7],[1,5,4,4,7]]

# Above test case suggested by @Shaggy
 Array: [-5,-2,-2,1,3,4,6]
Target: 0
Output: [[-5,-2,-2,3,6]]

 Array: [-5,-4,-2,0,1,2,6]
Target: 1
Output: [[-5,-2,0,2,6],[-4,-2,0,1,6]]

# Note that outputting `[[-4,-2,0,1,6],[-5,-2,0,2,6]]` is also valid,
# although returning just `[[-4,-2,0,1,6]]` or `[[-5,-2,0,2,6]]` is not.

 Array: [0,-1,2,3]
Target: 4
Output: -1

 Array: [0,1,-9,6,7]
Target: 6
Output: -1

 Array: [0,1,9,9,5]
Target: 45
Output: -1

 Array: [1,4,6,9,-4]
Target: 16
Output: [[1,4,6,9,-4]]

 Array: [1,0,9,6,5,0]
Target: 21
Output: [[1,0,9,6,5]]

 Array: [1,0,9,6,5,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

 Array: [1,0,9,6,5,4,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

# Above test case suggested by @Shaggy
 Array: [-5,-2,-2,1,3,4,6]
Target: 0
Output: [[-5,-2,-2,3,6]]

 Array: [-5,-4,-2,0,1,2,6]
Target: 1
Output: [[-5,-2,0,2,6],[-4,-2,0,1,6]]

# Note that outputting `[[-4,-2,0,1,6],[-5,-2,0,2,6]]` is also valid,
# although returning just `[[-4,-2,0,1,6]]` or `[[-5,-2,0,2,6]]` is not.

 Array: [0,-1,2,3]
Target: 4
Output: -1

 Array: [0,1,-9,6,7]
Target: 6
Output: -1

 Array: [0,1,9,9,5]
Target: 45
Output: -1

 Array: [1,4,6,9,-4]
Target: 16
Output: [[1,4,6,9,-4]]

 Array: [1,0,9,6,5,0]
Target: 21
Output: [[1,0,9,6,5]]

 Array: [1,0,9,6,5,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7]]

 Array: [1,0,9,6,5,4,4,7]
Target: 21
Output: [[1,0,9,6,5],[1,0,9,4,7],[0,6,4,4,7],[1,5,4,4,7]]

# Above test case suggested by @Shaggy
added 89 characters in body
Source Link
CrSb0001
  • 479
  • 2
  • 13

Inspiration: Leetcode's [3Sum] link

Inspiration: Leetcode's [3Sum] link

Added test case
Source Link
CrSb0001
  • 479
  • 2
  • 13
Loading
Source Link
CrSb0001
  • 479
  • 2
  • 13
Loading