We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Security
  3. Functions
  4. Security Bijective Functions

Security Bijective Functions

Problem
Submissions
Leaderboard
Discussions

HackerRank

|
  1. Prepare
  2. Security
  3. Functions
  4. Security Bijective Functions
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions

Now that we know about one-to-one functions, let's talk about onto functions and bijective functions.

A function is onto if and only if each element in the co-domain is the image of, at least, one element in the domain . That is:

If the function is both one-to-one and onto then is a bijection from to or, equivalently, is a bijective function.

In this task, you'll be given an integer and a function where . Determine whether the given function is a bijective function or not.

Constraints

Input Format

There are lines in the input.
The first line contains a single positive integer .
The second line contains space separated integers, the values of , respectively.

Output Format

On a single line, output "YES" if is bijective. Otherwise, output "NO".

Sample Input

3
1 2 3

Sample Output

YES

Explanation

Basically, this is the function .

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy