Two line ruby solution


  • 1
    B
    def remove_element(nums, val)
        nums.delete(val)
        return nums.size
    end
    

  • 0
    M

    6666666666666666666
    But it doesn't work by following method(it disturb me a lot):

    a = nums.clone
    a.delete(val)
    return a.size

Log in to reply
 

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