I am practicing some Dynamic Programming problems and encounter this problem
Given an array of n(1<=n<=1000)
integers and a positive integer k(k<=1000)
. Find the longest subsequence whose sum is divisible by k
.
For example, a = [1,6,11,5,10,15,20,2,4,9]
and k=5
.
The result should be: [9,4,20,15,10,5,11,6]
because 9+4+20+15+10+5+11+6 = 80
, which is divisible by 5.
What is a suitable approach to solve this problem?