MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / dfs

Method dfs

java/1235-maximum-profit-in-job-scheduling.java:19–36  ·  view source on GitHub ↗
(int i)

Source from the content-addressed store, hash-verified

17 }
18
19 private int dfs(int i) {
20 if (i == intervals.length) {
21 return 0;
22 }
23
24 if (cache[i] != null) {
25 return cache[i];
26 }
27
28 // don't include
29 int res = dfs(i + 1);
30
31 // include
32 int j = binarySearch(intervals, i, intervals[i][1]);
33 cache[i] = res = Math.max(res, intervals[i][2] + dfs(j));
34
35 return res;
36 }
37
38 private int binarySearch(int[][] intervals, int start, int target) {
39 int left = start + 1;

Callers 1

jobSchedulingMethod · 0.95

Calls 1

binarySearchMethod · 0.95

Tested by

no test coverage detected