Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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

Filter by
Sorted by
Tagged with
2
votes
3answers
180 views

Return all pairs from a list of integers that contributes to a given sum

Given a list of integers return all the pairs that makes up to a given target sum. input: {2, 7, 11, 15, -2} target sum: ...
10
votes
3answers
5k views

Finding indices of numbers that sum to a target

I've taken this algorithm question, which is to find the indexes of any two numbers in an array that sum to a given number. It is quite a simple problem to solve. But it is the execution time of my ...
9
votes
2answers
533 views

Hash table solution to twoSum

I try the most to solve a twoSum problem in leetcode Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input ...
8
votes
4answers
2k views

Find every possible pair of numbers that sum up to n number

I have this following code which find every possible pair of numbers that sum up to n number ...
2
votes
1answer
101 views

Find sum of 3 that total a target from a List

A related Java question got me curios. All unique combinations (not permutations) of 3 values that sum to a target from a list of integers. Values can duplicate in the list but are only used once. ...
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) ): ...
1
vote
1answer
261 views

Leetcode 3Sum problem using hashmap in Python

For practice, I solved Leetcode 15. 3Sum question: 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 ...