Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ejercicio de Fighter #44

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' of https://github.com/fahelodev/bc9
Lucas Gonzalez committed Jul 25, 2022
commit 69d6ae82d2f917d15a660ac6b4217e7e6e29d393
30 changes: 19 additions & 11 deletions src/main/java/nFigueroa/CountingDuplicates.java
Original file line number Diff line number Diff line change
@@ -25,22 +25,30 @@ public class CountingDuplicates {

public static int duplicateCount(String text) {

String textLower = text.toLowerCase();
char[] charArray = textLower.toCharArray();

//tomar el string y guardarlo en un array de char
char[] arrayList = text.toCharArray();
int contador=0;
String uniqueRepeats = ""; //Will keep track of unique repeats.
int count = 0;

for (int i = 0; i < arrayList.length; i++) {
//char auxiliar para comparar
char aux = arrayList[i];
for (int j = i+1; j < arrayList.length; j++) {
if(aux == arrayList[j]){
contador++;
for(int i = 0; i < charArray.length - 1; i ++) {
String restOfString = textLower.substring(i + 1);

//Convert single char to String to be used in method.
String character = Character.toString(charArray[i]);

//If not in uniqueRepeats, check if it is a repeat.
if(!uniqueRepeats.contains(character)) {
if(restOfString.indexOf(character) != -1) {
//If it is a repeat, increase count and concat it to uniqueRepeats
count++;
uniqueRepeats += character;
}
}
}
return count;
}
return contador;
}

public static void main(String []args){
System.out.println(duplicateCount("aabbcc"));
}
15 changes: 0 additions & 15 deletions src/main/java/nFigueroa/Multiplode3o5.java

This file was deleted.

14 changes: 0 additions & 14 deletions src/test/java/nFigueroa/Multiplode3o5Test.java

This file was deleted.

You are viewing a condensed version of this merge commit. You can view the full changes here.