Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
.
If n is the number of pieces, yes as i was talking about like two nested for loops, it is either O(n) or O(n * m) where n, m is height and length.
I also don't believe any solutions are O(n^2) if n is the number of pieces. By doing a simple nested loop with
for p in pieces:
twice, it times out.Your solution is much easier to understand! Months later, this is true for me, even though I wrote my code...
first things first: what is
n
exactly?@tony:
here, n being the number of pieces, the best solution is O(n) (for the precise reasons Ryanman is explaning)
I think O(n^2) is the lowest possible time as you need to have a nested loop. Take your solution for example, it has a nested loop, so its O(n^2).