Sort by

recency

|

1036 Discussions

|

  • + 0 comments

    Here is my Python solution!

    def gemstones(arr):
        gems = 0
        rocks = len(arr)
        minerals = set(list("".join(arr)))
        arr = [list(rock) for rock in arr]
        for mineral in minerals:
            if len([True for rock in arr if mineral in rock]) == rocks:
                gems += 1
        return gems
    
  • + 0 comments

    Here are my c++ approaches of solving this problem, video explanation here : https://youtu.be/EjhdJXN3a3c

    Solution 1 : Using a list of all possible characters

    int gemstones(vector<string> arr) {
        int result = 0;
        string liste = "abcdefghijklmnopqrstuvwxyz";
        for(int j = 0; j < liste.size(); j++){
            int cp = 0;
            for(int i = 0; i < arr.size(); i++){
                if(arr[i].find(liste[j]) != string::npos) cp++;
            }
            if(cp == arr.size())result++;
        }
        return result;
    }
    

    Solution 2 : Using set of the shortest element of the array of string

    string getShortest(vector<string> arr) {
        string result = arr[0];
        for(int i = 1; i < arr.size(); i++){
            if(arr[i].size() < result.size()) result = arr[i];
        }
        return result;
    }
    int gemstones(vector<string> arr) {
        int result = 0;
        string shortest = getShortest(arr);
        set<char> liste(shortest.begin(), shortest.end());
        for(auto j = liste.begin(); j != liste.end(); j++){
            int cp = 0;
            for(int i = 0; i < arr.size(); i++){
                if(arr[i].find(*j) != string::npos) cp++;
            }
            if(cp == arr.size())result++;
        }
        return result;
    }
    
  • + 0 comments
    
    
    let contadorPiedrasPreciosas = 0
    let piedras = []
    const rocas = []
    for (const rock of arr) {
        for (const p of rock ) {
            if (piedras.includes(p)) {
                continue;
            } else {
                piedras.push(p)
            }
        }
        rocas.push(piedras)
        piedras = []
    }
    for (const r of rocas) {
        for (const p of r) {
            aparicionPiedras[p] = (aparicionPiedras[p] || 0) + 1 
        }
    }
    for (const p in aparicionPiedras) {
        if (aparicionPiedras[p] === arr.length) {
            contadorPiedrasPreciosas++;
        }
    }
    return contadorPiedrasPreciosas``
    

    `

  • + 0 comments
    int gemstones(int arr_count, char** arr) {
        char* ok = NULL;
        int pres = 0, dragon = 0;
        for(char i = 'a';i <= 'z';i++) {
            for(int j = 0;j < arr_count;j++) {
                ok = strchr(arr[j],i);
                if(ok != NULL) {
                    pres++;
                }
                ok = NULL;
            }
            if(pres == arr_count) {
                dragon++;
            }
            pres = 0;
        }
        free(ok);
        return dragon;
    
  • + 0 comments

    Just as gemstones are minerals found in every rock of a collection, certain elements define a great racing game—speed, strategy, and precision. In gaming, discovering these essential features can enhance the experience, much like identifying gemstones in nature.

    At Drive Zone Online, we explore what makes racing games truly stand out, offering insights, guides, and updates for enthusiasts. Whether it's mastering techniques or finding the best modifications, understanding the core elements of a game can make all the difference.