Render a calendar - 14.4

#1

[EPIJ v 1.6.1 Problem 14.4]

I’ve implemented an O(n log n) time solution that uses sorting and PriorityQueue. I’d like to know if a solution is possible without using PriorityQueue, while still maintaining the same time bound.

0 Likes

#2

Easier approach will be using BST as whatever priority queue can do, BST can do as well.

0 Likes

#3

Cool. Thanks for the advice!

0 Likes

#4

Follow up question - Is a solution possible without BST, PriorityQueue, or other such data structure?

0 Likes

#5

It is possible by solving this by sorting.

0 Likes

#6

Thanks @tsunghsienlee. I was able to devise a solution with just sorting.

0 Likes

#7

whatever priority queue can do, BST can do as well

Not really, right? A priority queue can find min or max in O(1) time. A BST cannot. Am I missing something?

0 Likes