AlgoUniversity
  • Go Back
Discussion
3 Sum Equals K :

Author

HARSH PRIYADARSHI

Difficulty Level : Medium

Submissions : 825

Asked In : Mentor-Graphics

Marks :10

: 11 | : 1

You are given an array $$$A$$$ of $$$N$$$ integers and an integer $$$K$$$. You have to tell whether there exist three integers whose sum is equal to K. You can't use the integer at the same index twice. You have to print "Yes" if there exist such integers, otherwise "No". You can print "Yes" and "No" in any case.

Input

First line contains two integers N K $$$(3 \le N \le 10^3)$$$ - Number of integers in the array, $$$(0 \le K \le 10^9)$$$ - Target value

The next line contains N integers A1, A2, A3 ... An $$$(-10^8 \le Ai \le 10^8)$$$ - Element of the array A.

Output

Single line containing $$$True$$$ if the integers exist, otherwise $$$False$$$

Examples

Input
5 8
1 2 3 4 5
Output
Yes
Input
5 10
1 2 3 4 -1
Output
No

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.