1062

WA Code:

 Idea

The ships load in alphabetical order, so we can stack with respect to the alphabet. Start with one stack and add the first letter. From then on, check each stack to see if the current letter can be added. If the current letter is less than or equal to the one on top of a stack, add it to that stack. Otherwise, check the next one. If none of the letters on top of any stacks can support the current container, add a new stack to the vector and increment your count.

 

Leave a Reply

Your email address will not be published. Required fields are marked *