Questions tagged [k-sum]

Given a set of numbers, a target sum, and some k, the problem of finding a subset of size k that has the target sum

4 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
59 views

Solution to 3Sum problem on Leetcode using HashTable

The problem of 3sum is described as: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero....
2
votes
1answer
43 views

Printing all the combination of indexes for 2 sum exact outcome

Can somebody review the code and provide suggestions on where I can improve on the code like use of better data structure etc. Input: {1,7,2,8,3,6}, 9 Output: [0, 3] [1, 2] [4, 5] ...
1
vote
0answers
62 views

Closest 3Sum in Scala

This question is taken from Leet code. Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three ...
1
vote
0answers
77 views

Check if list contains 3 elements with predefined sum

I have 2 solutions about puzzle I mentioned in title: solution 1( O(n^3) ): ...