0

I have array of numbers and I want to find a subarray with given sum, Ive googled a lot but all explanations were for case where subarray is continuous. What if I dont need it to be continuous? how can I find it?

Zhani Baramidze
  • 1,369
  • 11
  • 30

1 Answers1

0

Google for subset sum instead. This is a weakly NP hard problem, meaning it's solvable for integers by a classical dynamic program with runtime proportional to the magnitude of the elements in the set. This is exponential time.

Gene
  • 44,980
  • 4
  • 53
  • 91