GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 5 October 2022

[Solution] Chef and Happy String CodeChef Solution


Problem

Chef has a string S with him. Chef is happy if the string contains a contiguous substring of length strictly greater than 2 in which all its characters are vowels.

Determine whether Chef is happy or not.

Note that, in english alphabet, vowels are aeio, and u.

Input Format

  • First line will contain T, number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, a string S.

Output Format

For each test case, if Chef is happy, print HAPPY else print SAD.

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

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Explanation:

Test case 1: Since the string aeiou is a contiguous substring and consists of all vowels and has a length \gt 2, Chef is happy.

Test case 2: Since none of the contiguous substrings of the string consist of all vowels and have a length \gt 2, Chef is sad.

Test case 3: Since none of the contiguous substrings of the string consist of all vowels and have a length \gt 2, Chef is sad.

Test case 4: Since the string eea is a contiguous substring and consists of all vowels and has a length \gt 2, Chef is happy.

No comments:

Post a Comment