Security Bijective Functions

Sort by

recency

|

81 Discussions

|

  • + 0 comments

    quite hard to understand the question - only really became clear after stumbliing across the right answer - very easy once you get past the wordingof the explanation

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    n = int(input().strip())
    arr = [int(i) for i in input().strip().split()]
    ans = "YES"
    for i in range(1,n+1):
        if i not in arr:
            ans = "NO"
    print(ans)
    
  • + 0 comments

    C++ solution with std::map like a table of frequencies :

    #include <iostream>
    #include <map>
    
    using namespace std;
    
    int main() {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
        int n;
        cin>>n;
        map<int,int> freqeuncy;
        bool isTrue = true;
        for(int i=0;i<n;i++){
            int t;
            cin>>t;
            if(freqeuncy.find(t)==freqeuncy.end()){
                freqeuncy[t] = 1;
            }else {
                isTrue = false;
            }
        }
        isTrue ? cout<<"YES" : cout<<"NO";
        cout<<endl;  
        return 0;
    }
    
  • + 0 comments

    def check(x,y): if x==len(set(y)): return "YES" else: return "NO" n=int(input()) m=list(map(int,input().split())) print(check(n,m))

  • + 0 comments

    Very poor explanation, and the absence of sample test cases is even more frustrating.

  • + 0 comments

    My solution in Python 3:

    t=int(input())
    s=list(map(int,input().split()))
    if len(set(s)) == t:
        print("YES")
    else:
        print("NO")