No one has replied
Yes, I think it is better and safer to remove element by its index rather than the concrete element itself. Also, Why not use switch case?
Do not use eval. You are not supposed to use it to solve this problem.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.