JSMongere / Test2

0 stars 0 forks source link

injective function #2

Open mrfltvs opened 7 months ago

mrfltvs commented 7 months ago

cpp

include

include

bool isInjective(int arr[], int n) { std::unordered_set values;

for (int i = 0; i < n; i++) {
    if (values.find(arr[i]) != values.end()) {
        return false;
    }
    values.insert(arr[i]);
}
return true;

}

int main() { int arr[] = {1, 2, 3, 4, 5}; int n = sizeof(arr) / sizeof(arr[0]);

if(isInjective(arr, n)) {
    std::cout << "The function is injective." << std::endl;
} else {
    std::cout << "The function is not injective." << std::endl;
}

return 0;

}

mrfltvs commented 7 months ago

int main() { Blockchain blockchain;

Block block1("Block 1 Data", blockchain.getLatestBlock().getHash());
blockchain.addBlock(block1);