My solution: javascript with es6


  • 0
    H
    var removeDuplicates = function(nums) {
        return Array.from(new Set(nums));
    };
    

    not support es6?


  • 0
    D

    I tried your answer as well. It should pass, but it doesn't.

    Mine is a less efficient version of your answer, which does not pass either. Both works on node however.

    var removeDuplicates = function(nums) {
        let set = new Set()
        for (value of nums) {
            set.add(value)
        }
        return Array.from(set) // or set.size
    };
    

Log in to reply
 

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