Chef calls a number lucky if it contains the digit 77 at least once.
Given a number XX, determine if it is a lucky number or not.
Input Format
- The first line contains a single integer TT — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains an integer XX — the number mentioned in the problem statement.
Output Format
For each test case, output YES if XX is a lucky number. Otherwise, output NO.
You may print each character of YES and NO in uppercase or lowercase (for example, yes, yEs, Yes will be considered identical).
Constraints
- 1 ≤T≤1000
- 1 ≤X≤10^9
Sample 1:
Input:
4 6 478 2090 77777
Output:
NO YES NO YES
Explanation:
Test Case 1: The number 66 is not lucky since it does not contain the digit 77.
Test Case 2: The number 478478 is lucky since it contains the digit 77 at least once.
Test Case 3: The number 20902090 is not lucky since it does not contain the digit 77.
Test Case 4: The number 7777777777 is lucky since it contains the digit 77 at least once.
Solution
/* 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. */
/* 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
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
String s = Integer.toString(n);
if(s.contains("7")){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
}
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] Lucky Numbers STARTERS 73 CodeChef [Solved] Lucky Numbers STARTERS 73 CodeChef](https://realcoder.techss24.com/wp-content/uploads/2023/01/Solved-Lucky-Numbers-STARTERS-73-CodeChef.png)
![[Solved] Book Fair with Java, C++, Python](https://realcoder.techss24.com/wp-content/uploads/2023/02/Solved-Book-Fair-with-Java-C-Python-300x169.png)
![[Solved] You are required to fix all syntactical errors in the given code](https://realcoder.techss24.com/wp-content/uploads/2022/11/Solved-You-are-required-to-fix-all-syntactical-errors-in-the-given-code-300x196.png)
![[Solved] Swap Shift January Long 2023 CodeChef](https://realcoder.techss24.com/wp-content/uploads/2023/01/Solved-Swap-Shift-January-Long-2023-CodeChef-300x200.png)