Time complexity of this solution

Правка en1, от fmoeran, 2023-05-15 23:35:26

I really don't mean to bother anyone, this has just been annoying me for a good amount of time.

The problem is 855F. I seem to have a working solution but it's timing out at test 38.

I thought my solution worked in O(n) but it clearly either doesn't or something else is very wrong. My thought process was that both makeWanted and dfs should work in O(n) since there are no loops in a tree, so solve() should be O(n) as well.

I'd be incredibly thankful if you could have a look and see where I'm wrong :)

Теги time complexity, graphs, trees

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский fmoeran 2023-05-16 00:08:02 25
en1 Английский fmoeran 2023-05-15 23:35:26 658 Initial revision (published)