C++ One-Liner, 3ms

  • 0

    It's always good to show you know your standard library before re-implementing things.

    class Solution {
        int removeElement(vector<int>& nums, int val) {
            return std::distance(nums.begin(), std::remove(nums.begin(), nums.end(), val));

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.