Lonely Integer

Sort by

recency

|

465 Discussions

|

  • + 0 comments

    Python 3 Solution Readable & Optimised

    def lonelyinteger(a): for i in a: if a.count(i)==1: return i

  • + 0 comments
        public static int lonelyinteger(List<int> a)
        {
            return a.GroupBy(i => i).Single(g => g.Count() == 1).Key;
        }
    
  • + 0 comments

    One liner:

    return [i for i in a if a.count(i) == 1][0]
    
  • + 0 comments

    counters: def lonelyinteger(a): times = Counter(a)

    q =[k for k in times if times[k]==1]
    return q[0]
    
  • + 0 comments

    I wanna recieve feedback about my Javascript solution, thxs!:

    function lonelyinteger(a) {
        // Write your code here
        a.sort((a, b) => a - b);
        let aux=0
        for(let i=0;i<a.length;i++){
            if(a[i]!=a[i+1]) aux=a[i]
            else i++
        }
        return aux;
    
    }