| 1 | public class FrogJump { |
| 2 | static int best(int[] h, int n, int idx){ |
| 3 | if(idx == n-1) return 0; |
| 4 | int op1 = Math.abs(h[idx] - h[idx+1]) + best(h, n, idx+1); |
| 5 | if(idx == n-2) return op1; |
| 6 | int op2 = Math.abs(h[idx] - h[idx+2]) + best(h, n, idx+2); |
| 7 | return Math.min(op1, op2); |
| 8 | } |
| 9 | |
| 10 | public static void main(String[] args) { |
| 11 | int[] h = {10, 30, 40, 20}; |
| 12 | System.out.println(best(h, h.length, 0)); |
| 13 | } |
| 14 | } |
nothing calls this directly
no outgoing calls
no test coverage detected