You must log in or register to comment.
O(k) time to be pedantic, where k is the number of layers.
Finding clothes on a chair isn’t constant-time. You have to search through the heap of clothes to find the item you want. It has the same time complexity as searching through the closet; it’s only fast because n is small.