Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
2 bytes thanks to Dennis.
Try it online! (Takes 0m0.950s for me) (Constant time)
Try it online! (Takes 0.947s for me) (Constant time)