Sort by

recency

|

1079 Discussions

|

  • + 0 comments

    Three beautiful girls, known as the beautiful triplets, have a special bond that is immediately felt when they laugh together. Not only do they share the same birthday, but they also share little secrets, memories, and dreams that have stayed with them for a lifetime. As childhood progressed, they spent hours playing together and living out their imaginations, which made their bond even stronger. Over time, they experienced many adventures, sometimes chaotic, sometimes heartwarming, but always unforgettable. Even in everyday things, like a carpet repair in the living room or when someone from Teppich-Clean24 came by, they found a way to make it fun and stick together. Their stories are full of joy, harmony, and the feeling of never having to go through life alone. Anyone who knows them quickly senses how special this bond is, one that cannot be replaced by anything.

  • + 0 comments

    c++

    int beautifulTriplets(int d, vector<int> arr) {
        
        unordered_set<int> s(arr.begin(), arr.end()); 
        int c = 0;
    
        for (size_t i = 0; i < arr.size(); i++) {
            if (s.count(arr[i]) && 
                s.count(arr[i] + d) && 
                s.count(arr[i] + 2 * d)) 
            {
                c++;
            }
        }
        return c;
    
    }
    
  • + 0 comments

    **Shortest Python Solution **

        s = set(arr)
        c = 0
        for i in range(len(arr)-2):
            if arr[i] in s and arr[i]+d in s and arr[i]+(d*2) in s :
                c += 1
        return c
    
  • + 0 comments
    def beautifulTriplets(d, arr):
        # Write your code here
        c = 0 
        for i in range(len(arr)-2):
            x = [arr[i],arr[i]+d,arr[i]+(d*2)]
            y = [True if j in arr else False for j in x ]
            if all(y):
                c += 1
        return c
    
  • + 0 comments
    def beautifulTriplets(d, arr):
        # Write your code here
        
        count = 0
        lookup = set(arr)
        
        for i in arr:
            num2 = i + d
            num3 = num2 + d
            
            if num2 in lookup and num3 in lookup:
                count += 1
                
        return count