Python Enum and Pydantic : accept enum member’s composition

The bounty expires in 3 days. Answers to this question are eligible for a +250 reputation bounty. Ethan Furman wants to reward an existing answer. I have an enum : from enum import Enum class MyEnum(Enum): val1 = “val1” val2 = “val2” val3 = “val3” I would like to validate a pydantic field based on … Read more

Mathematical explanation of Leetcode question: Container With Most Water

I was working on a medium level leetcode question 11. Container With Most Water. Besides the brute force solution with O(n^2), there is an optimal solution with complexity of O(n) by using two pointers from left and right side of the container. I am a little bit confused why this “two pointers” method must include the optimal solution. Does anyone know how to prove the correctness of this algorithm mathematically? This is an algorithm that I don’t know of. Thank you!