There are some solutions using some built in method to solve this problem? But almost every one got down vote, why?
Because it is so trivial.
We can not learn or practice from such trivial solutions.
However in real world, it is often unnecessary to reinvent the wheel, so please use the built-in functions freely...:-)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.