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,407
  • 1
  • 13
  • 32

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
  • 46,253
  • 4
  • 58
  • 96