ProtyayMnd50 revised this gist . Go to revision
1 file changed, 22 insertions
ABCheck.java(file created)
@@ -0,0 +1,22 @@ | |||
1 | + | // code for ABCHeck question | |
2 | + | import java.util.*; | |
3 | + | import java.io.*; | |
4 | + | ||
5 | + | class Main { | |
6 | + | ||
7 | + | public static String ABCheck(String str) { | |
8 | + | str = str.toLowerCase(); // Make case insensitive | |
9 | + | for (int i = 0; i < str.length() - 4; i++) { | |
10 | + | if ((str.charAt(i) == 'a' && str.charAt(i + 4) == 'b') || | |
11 | + | (str.charAt(i) == 'b' && str.charAt(i + 4) == 'a')) { | |
12 | + | return "true"; | |
13 | + | } | |
14 | + | } | |
15 | + | return "false"; | |
16 | + | } | |
17 | + | ||
18 | + | public static void main(String[] args) { | |
19 | + | Scanner s = new Scanner(System.in); | |
20 | + | System.out.print(ABCheck(s.nextLine())); | |
21 | + | } | |
22 | + | } |
Newer
Older