algorithm - lowest absolute change from n numbers with k pass overs -


i need algorithm, finds out lowest sum of absolute changes in sequence of n numbers, can pass on k numbers. example:

6(n) 2(k)
3 5 2 5 3 4
withous pass overs, have sum of absolute changes that:
3-5=-2 >>> 2
2-5=-3 >>> 3
5-2=3 >>> 3
3-5=2 >>> 2
4-3=1 >>> 1
sum:11 after skipping first 2 , second 3, have 5-3=2 5-5=0,4-3=-1 >> 1, sum 3. @ moment found out way see posible consistent pass overs value of possible decrease skip. here is:

htt ps://ide one.com/g qznce (i couldnt past link on phone)


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -