package kapitel_13 /** * Beispiel aus * * - Algorithmen und Datenstrukturen für Dummies * - von Andreas Gogol-Döring und Thomas Letschert * - Verlag Wiley-VCH; Oktober 2019 * - Kapitel 13, Dynamisches Programmieren * * @author A. Gogol-Döring, Th. Letschert */ object AuD_13_01_MaxSubSumBF_App extends App { def maxsubSumBF(a: Array[Int]): Int = (for (l <- 0 until a.length; r <- l until a.length ) yield ( for (i <- l to r) yield a(i) ).sum ).max val a = Array(1, -4, 3, 18, 1, -8, 2, -1, 10, -5, -80, 20, 3, -2) println(maxsubSumBF(a)) // 25 }