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

Method bookHelper

java/0729-my-calendar-i.java:15–34  ·  view source on GitHub ↗
(CalendarNode cur, int targetStart, int targetEnd)

Source from the content-addressed store, hash-verified

13 }
14
15 private boolean bookHelper(CalendarNode cur, int targetStart, int targetEnd) {
16 if (targetStart > cur.end) {
17 // go to the right
18 if (cur.right == null) {
19 // we can insert event
20 cur.right = new CalendarNode(targetStart, targetEnd);
21 return true;
22 }
23 return bookHelper(cur.right, targetStart, targetEnd);
24 } else if (targetEnd < cur.start) {
25 // go to the left
26 if (cur.left == null) {
27 // we can insert event
28 cur.left = new CalendarNode(targetStart, targetEnd);
29 return true;
30 }
31 return bookHelper(cur.left, targetStart, targetEnd);
32 }
33 return false;
34 }
35}
36
37class CalendarNode {

Callers 1

bookMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected