Skip to content

Commit 91d3ed1

Browse files
authored
Create Check AB
1 parent 756ae53 commit 91d3ed1

File tree

1 file changed

+27
-0
lines changed
  • Course 2 - Data Structures in JAVA/Recursion Assignment

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Suppose you have a string, S, made up of only 'a's and 'b's. Write a recursive function that checks if the string was generated using the following rules:
3+
a. The string begins with an 'a'
4+
b. Each 'a' is followed by nothing or an 'a' or "bb"
5+
c. Each "bb" is followed by nothing or an 'a'
6+
If all the rules are followed by the given string, return true otherwise return false.
7+
8+
Input format :
9+
String S
10+
11+
Output format :
12+
'true' or 'false'
13+
14+
Constraints :
15+
0 <= |S| <= 1000
16+
where |S| represents length of string S.
17+
18+
Sample Input 1 :
19+
abb
20+
Sample Output 1 :
21+
true
22+
23+
Sample Input 2 :
24+
abababa
25+
Sample Output 2 :
26+
false
27+
*/

0 commit comments

Comments
 (0)