The user has provided 2 methods. The 2nd method is used while the space complexity is not an issue and also while the user wants Stability; the 2nd approach is used to maintain the order of the elements.