We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0f9159 commit d5d73acCopy full SHA for d5d73ac
Data Structures in Java/Level 1/Lecture 4 - Recursion 2/Recursion2_RemoveX.java
@@ -0,0 +1,26 @@
1
+
2
+public class Recursion2_RemoveX {
3
4
+ public static String removeX(String str) {
5
6
+ if(str.length()==0) {
7
+ return str;
8
+ }
9
10
+ if(str.charAt(0)=='x') {
11
+ return removeX(str.substring(1,str.length()));
12
13
+ else {
14
+ return str.charAt(0) + removeX(str.substring(1,str.length()));
15
16
17
18
19
+ public static void main(String[] args) {
20
21
+ String str = "xbxa";
22
+ System.out.println(removeX(str));
23
24
25
26
+}
0 commit comments