Title
class Solution {
public String removeDuplicates(String s) {
String finalString = s;
int stringLength = finalString.length();
while (stringLength > 1) {
for (int i = 0; i < finalString.length() - 1; i++) {
if (finalString.charAt(i) == finalString.charAt(i + 1)) {
finalString = finalString.substring(0 , i) + finalString.substring(i + 2, finalString.length());
stringLength -= 2;
}
}
}
return finalString;
}
public static void main(String[] args) {
Solution myObj = new Solution();
System.out.println(myObj.removeDuplicates("abbaca"));
}
}
Solution.main(null);
public class Main {
public static void main(String[] args) {
int[] numbers = {5, 12, 8, 2, 91, 23, 16, 56, 38, 72};
int swapCount = 0;
for (int i = 0; i < numbers.length - 1; i++) {
if (numbers[i] > numbers[i + 1]) {
int temp = numbers[i + 1];
numbers[i + 1] = numbers[i];
numbers[i] = temp;
swapCount++;
}
if (i == numbers.length - 2 && swapCount != 0) {
swapCount = 0;
i = -1;
}
}
for (int number : numbers) {
System.out.println(number);
}
}
}
Main.main(null);
public class Country {
// properties
}
public class Main {
// properties, methods, and ArrayList
public static void main(String[] args) {
}
}
public void Pyramid(int n) {
for (int i = 1; i <= n; i++) {
System.out.println("*");
System.out.println();
Pyramid(n - 1);
}
}
Pyramid(10);
public void drawLine(int n)
{
for (int i = 1; i <= n; i++) {
System.out.print("*");
System.out.println();
drawLine(n - 1);
}
}
drawLine(10);
Main.main(null);