Improved the solution to the PermMissingElem problem in C++