# Favourite String of Chef CodeChef Solution – Code Drive solution 2022

## About Favourite String of Chef CodeChef Solution

• This is a coding contest based on algorithms, data structures, and problem-solving.
• Organizer: The contest is hosted by NIT Trichy.
• Prizes: NA
• Registrations for prizes: NA

### Problem: Favourite String of Chef CodeChef Solution

A string SS is called Chef’s favourite if every substring `chef` in SS must have a substring `code` before it.

You are given a string SS of size NN that contains both `code` and `chef` as a substring. Please determine if SS is Chef’s favourite.

Note: A substring is a continuous part of a string that can be obtained by deleting some (maybe none) characters from the beginning and some (maybe none) characters from the end.

### Input Format

• The first line of the input contains an integer TT – the number of test cases. The test cases then follow.
• The first line of each test contains an integer NN – the size of the string.
• The second line of each test contains a string SS.

### Output Format

For each test case, output on a single line `AC` if SS is Chef’s favourite, or `WA` otherwise.

### Constraints

• 1≤T≤101≤T≤10
• 1≤N≤1041≤N≤104
• |S|=N|S|=N
• SS consists only of lowercase English characters
• Both `code` and `chef` appear as a substring at least once in SS

### Sample Input 1

``````4
8
codechef
8
chefcode
14
sxycodeghychef
21
sxychefvsvcodehghchef
``````

### Sample Output 1

``````AC
WA
AC
WA
``````

### Explanation

• Test case 11: Substring `code` is present before `chef`.
• Test case 22: Substring `code` is not present before `chef`.
• Test case 33: Substring `code` is present before `chef`.
• Test case 44: There is no `code` substring present before the first occurrence of `chef`.

## Solution of Favourite String of Chef CodeChef Solution

``````Solution in Python :

for _ in range(int(input())):
n=int(input())
#l=list(map(int,input().split()))
s=input()
if s.find("code")<s.find("chef"):
print("AC")
else : print("WA")
``````

#### Contest Details:

• This is an External Rated Contest.
• Duration: 3 Hours
• Start time: 30th December 2021, 20:00 hrs IST
• End time: 30th December 2021, 23:00 hrs IST
You may check your timezone here.
• This contest is rated only for Division 2 and Division 3 users. Division 1 users can participate unofficially in this contest.

Get More CodeChef Solution >>

Substring Minimum Function FizzBuzz Solution

Magical Planks Fizzbuzz Solution

error: Content is protected !!