File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ I have also solved other domains on HackerRank that can be viewed at:
149
149
| [ Two Characters] ( https://www.hackerrank.com/challenges/two-characters ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/strings/TwoCharacters.java ) |
150
150
| [ Caeser Cipher] ( https://www.hackerrank.com/challenges/caesar-cipher-1 ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/strings/CaesarCipher.java ) |
151
151
| [ Mars Exploration] ( https://www.hackerrank.com/challenges/mars-exploration ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/strings/MarsExploration.java ) |
152
- | [ HackerRank Is a String!] ( https://www.hackerrank.com/challenges/hackerrank-in-a-string ) | Easy | |
152
+ | [ HackerRank In a String!] ( https://www.hackerrank.com/challenges/hackerrank-in-a-string ) | Easy | |
153
153
| [ Pangrams] ( https://www.hackerrank.com/challenges/pangrams ) | Easy | |
154
154
| [ Weighted Uniform Strings] ( https://www.hackerrank.com/challenges/weighted-uniform-string ) | Easy | |
155
155
| [ Separate The Numbers] ( https://www.hackerrank.com/challenges/separate-the-numbers ) | Easy | |
Original file line number Diff line number Diff line change
1
+ // https://www.hackerrank.com/challenges/hackerrank-in-a-string/problem
2
+
3
+ package strings ;
4
+
5
+ import java .util .*;
6
+
7
+ public class HackerRankInAString {
8
+ private static final String HACKERRANK = "hackerrank" ;
9
+
10
+ public static void main (String [] args ) {
11
+ Scanner scanner = new Scanner (System .in );
12
+ int queries = scanner .nextInt ();
13
+ while (queries -- > 0 ) {
14
+ String string = scanner .next ();
15
+ System .out .println (containsHackerRank (string ) ? "YES" : "NO" );
16
+ }
17
+ }
18
+
19
+ private static boolean containsHackerRank (String string ) {
20
+ for (int index = 0 , pointer = 0 ; index < string .length () ; index ++) {
21
+ if (string .charAt (index ) == HACKERRANK .charAt (pointer )) {
22
+ pointer ++;
23
+ }
24
+ if (pointer == HACKERRANK .length ()) {
25
+ return true ;
26
+ }
27
+ }
28
+ return false ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments