729. My Calendar I

solution1: use common arraylist compare interval

time: O(n), use m times, O(m*n)

space: O(n)

solution2: use TreeMap

10, 20

15 25

lowerKey(end) => just like this, we find the array start data < end

use end key to find lower key => so get the data[0]'key

then use this data[0]'key to get data[1]'key

time: O(logn), use m times, O(mlogn)

space: O(n)

use native tree, faster but too long...

latest easy version

Last updated

Was this helpful?