MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / compute

Method compute

src/class130/Code01_JumpRight.java:57–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55 }
56
57 public static int compute() {
58 dp[0] = arr[0];
59 l = r = 0;
60 for (int i = 1; i <= n; i++) {
61 add(i - a);
62 overdue(i - b - 1);
63 dp[i] = l < r ? dp[queue[l]] + arr[i] : NA;
64 }
65 int ans = NA;
66 for (int i = n + 1 - b; i <= n; i++) {
67 ans = Math.max(ans, dp[i]);
68 }
69 return ans;
70 }
71
72 public static void add(int j) {
73 if (j >= 0 && dp[j] != NA) {

Callers 1

mainMethod · 0.95

Calls 3

addMethod · 0.95
overdueMethod · 0.95
maxMethod · 0.45

Tested by

no test coverage detected