The Three Topics CodeChef Solution

Problem – The Three Topics CodeChef Solution

The Chef has reached the finals of the Annual Inter-school Declamation contest.

For the finals, students were asked to prepare 10 topics. However, Chef was only able to prepare three topics, numbered AB and C — he is totally blank about the other topics. This means Chef can only win the contest if he gets the topics AB or C to speak about.

On the contest day, Chef gets topic X. Determine whether Chef has any chances of winning the competition.

Print “Yes” if it is possible for Chef to win the contest, else print “No”.

You may print each character of the string in either uppercase or lowercase (for example, the strings yEsyesYes, and YES will all be treated as identical).

Input Format

  • The first and only line of input will contain a single line containing four space-separated integers ABC, and X — the three topics Chef has prepared and the topic that was given to him on contest day.

Output Format

  • For each testcase, output in a single line “Yes” or “No”.
  • You may print each character of the string in either uppercase or lowercase (for example, the strings yEsyesYes, and YES will all be treated as identical).

Constraints

  • 1≤A,B,C,X≤10
  • A,B,C are distinct.

Subtasks

Subtask #1 (100 points): Original constraints

Sample 1:

Input: 2 3 7 3
Output: Yes

Explanation:

Chef had prepared the topics: 2,3,7. Chef gets to speak on the topic: 3. Since Chef had already prepared this, there is a chance that he can win the contest.

Sample 2:

Input: 4 6 8 5
Output: No

Explanation:

Chef had prepared the topics: 4,6,8. Chef gets to speak on the topic: 5. Since Chef didn’t prepare this topic, there is no chance that he can win the contest.

The Three Topics CodeChef Solution in Pyth 3

a,b,c,x=map(int,input().split())
if x in [a,b,c]:
    print("yes")
else:
    print("no")

The Three Topics CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int a, b, c, x;
	cin>>a>>b>>c>>x;
	if (x==a || x==b || x==c)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

The Three Topics CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner in = new Scanner(System.in);
		int a[] = new int[3];
		for(int i=0;i<3;i++){
		    a[i]=in.nextInt();
		}
		int X = in.nextInt();
		boolean flag=false;
		for(int i=0;i<3;i++){
		    if(X==a[i]){
		        flag=true;
		        break;
		    }
		}
		System.out.println(!flag?"No":"Yes");
	}
}
The Three Topics CodeChef Solution Review:

In our experience, we suggest you solve this The Three Topics CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the The Three Topics CodeChef Solution

Find on CodeChef

Conclusion:

I hope this The Three Topics CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published.