Hi @Jon_Barker,
Thank you for reaching out and sharing your observations regarding the code snippet.
I would like to clarify that the expression capitals_min_heap[0][0]
actually retrieves the value of the first element (capital) from the min-heap, not its index. You can verify this by printing this line of code and see if the index is returned or the value.
The line capitals_min_heap[0][0] <= current_capital
checks if the smallest capital in the min-heap is less than or equal to the current capital. It’s crucial for dynamically selecting capitals within a specific range, contributing to the efficient calculation of the maximum capital in the maximum_capital
function.
I hope this helps clear your confusion regarding the code. Please feel free to share any more feedbacks or suggestions, we’d be happy to help. Thanks!
Happy learning!