Question: HELP CODING WITH JAVA Situation #2. You are given a String str and you need to modify it as described in this problem The one
HELP CODING WITH JAVA
Situation #2.
You are given a String str and you need to modify it as described in this problem

The one below is with recursion

Here is my code that is given
public static String removeMystery1(String str) {
int[] array = new int[str.length()];
String newStr = "";
int sum = 0;
int increment = -1;
for (int i=0; i sum = sum + ((increment++) + 1); array[i] = sum; } boolean addIndexOrNot = true; for (int i = 0; i for (int j = 0; j if (i == array[j]) addIndexOrNot = false; } if (addIndexOrNot) { char currentChar = str.charAt(i); newStr = newStr + currentChar; } addIndexOrNot = true; } return newStr; } and: public static String removeMystery2(String str) { String result = ""; int toBeRemoved=0; int count = 1; // this for loop looks at every char of str and decides whether to copy it in result or not. for (int i = 0; i // decide whether to copy char in result if (i != toBeRemoved) { result += str.charAt(i); } else { toBeRemoved = toBeRemoved + count; count++; } } return result; } Your job is the following: Table that you have to fill out: Input string removeMystery1withNumSteps removeMystery2withNumSteps abcdef abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
